JBoss Initial Context


EJB design: JBoss Initial Context

  1. JBoss Initial Context (14 messages)

    Hi all, I need some help for define my initial context for JBoss i have this:

    private Context getInitialContext() throws Exception {

             Properties properties = null;
            try {
              properties = new Properties();

     properties.setProperty("java.naming.provider.url", "http://localhost:1099");
     properties.setProperty("java.naming.factory.url.pkgs", "org.jnp.interfaces.NamingContextFactory");

            catch (Exception ex) {
               error += ex.getMessage();
        return new InitialContext(properties);

    But it don't works, any help?

    Threaded Messages (14)

  2. Can you post more information![ Go to top ]

    Can you post more information, is localhost resolving on your box? The same configuration works for me on my 3.2.3 setup of jboss?
  3. more info required[ Go to top ]


    Can u give me more info regarding the error u r getting .....

    krishna kishore
  4. more info required[ Go to top ]

    What error ?. error stack trace pls

  5. ejb with jboss[ Go to top ]

    hi hello ,
    can i know how to integrate or deploying in the jboss
    as i am getting the error like this ..........since i used to do with weblogic right now i am not having weblogic and i am using jboss 5.0.error is like this

    Exception in thread "main" javax.naming.NoInitialContextException: Cannot instantiate class: jboss.jndi.WLInitialContextFactory [Root exception is java.lang.ClassNotFoundException: jboss.jndi.WLInitialContextFactory]

    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.(Unknown Source)

    at com.nit.ejb2.TestClient.main(TestClient.java:14)

    Caused by: java.lang.ClassNotFoundException: jboss.jndi.WLInitialContextFactory

    at java.net.URLClassLoader$1.run(Unknown Source)

    at java.security.AccessController.doPrivileged(Native Method)

    at java.net.URLClassLoader.findClass(Unknown Source)

    at java.lang.ClassLoader.loadClass(Unknown Source)

    at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)

    at java.lang.ClassLoader.loadClass(Unknown Source)

    at java.lang.Class.forName0(Native Method)

    at java.lang.Class.forName(Unknown Source)

    at com.sun.naming.internal.VersionHelper12.loadClass(Unknown Source)

    ... 5 more

    i have wriitenn small slsb programme but i want to deploy the jar in jboss but it is showing the above error
  6. JBoss Initial Context[ Go to top ]

    Ok I have an application that runs on weblogic 8.1, but I want to change to the jboss application server, in the application I use EJBs 2.0 and relationships, I am using JBuilder 9 as IDE, I configure JBuilder to use JBoss and it automatically generate the ejb-jax.xml, jboss.xml and jbosscmp-jdbc.xml

    ********when I call a finder for example, I do this***************

        try {
          context = getInitialContext();

          Object homeObject = context.lookup("apas.ApasAsociacionRemote");

         asociacionHome = (ApasAsociacionRemoteHome) PortableRemoteObject.
              homeObject, ApasAsociacionRemoteHome.class);

          Integer tipIdentInt = new Integer(0);
          Long numIdentLong = new Long(601620454);

          answer = asociacionHome.getByTipIdentNumIdent(
              tipIdentInt, numIdentLong);
        catch (Exception ex) {
          error += ex;

    ********This is the function that return the initialContext**********

      private Context getInitialContext() throws Exception {
             Properties properties = null;
            try {
              properties = new Properties();
              properties.put("java.naming.factory.initial", "org.jnp.interfaces.NamingContextFactory");
              properties.put("java.naming.factory.url.pkgs", "org.jnp.interfaces.NamingContextFactory");
            catch (Exception ex) {
               error += ex.getMessage();
        return new InitialContext(properties);

    ********************* This is the error*****************

    08:32:09,592 WARN [ServiceController] Problem starting service jboss.j2ee:jndiN
    org.jboss.deployment.DeploymentException: Mappings were not provided for all fie
    lds: unmaped fields=[tip_Identificacion, num_Identificacion] in role=ApasAsociac

    ********************* Also ***********************

     I Depend On:
     Depends On Me: org.jboss.deployment.DeploymentException: Mappings were not prov
    ided for all fields: unmaped fields=[tip_Identificacion, num_Identificacion] in
    role=ApasAsociacionSocioRelationshipRole, ObjectName: jboss.j2ee:jndiName=apas.A
     state: FAILED
    tip_Identificacion, num_Identificacion are the keys of the EJB

    Thanks for your help
    regards Daniel
  7. JBoss Initial Context[ Go to top ]

    Ok, i only upload one EJB and I get this exception:

    javax.naming.CommunicationException: Receive timed out [Root exception is java.net.SocketTimeoutException: Receive timed out]
  8. JBoss Initial Context[ Go to top ]

    That on my application with a try catch and on the JBoss console:

    16:02:08,857 WARN [NamingContext] Failed to connect to http:1099
    javax.naming.CommunicationException: Failed to connect to server http:1099. Roo
    t exception is
    javax.naming.ServiceUnavailableException: Failed to connect to server http:1099.
      Root exception is
    java.net.UnknownHostException: http: http
            at java.net.InetAddress.getAllByName0(InetAddress.java:948)
            at java.net.InetAddress.getAllByName0(InetAddress.java:918)
            at java.net.InetAddress.getAllByName(InetAddress.java:912)
            at java.net.InetAddress.getByName(InetAddress.java:832)
            at org.jnp.interfaces.TimedSocketFactory.createSocket(TimedSocketFactory...

    Please I need help!
    Regards Daniel
  9. JBoss Initial Context[ Go to top ]

    2004-06-04 08:16:22,490 INFO [org.jboss.ejb.EjbModule] Deploying OutstandingOrders
    2004-06-04 08:16:24,271 INFO [org.jboss.ejb.plugins.StatelessSessionInstancePool] Started jboss.j2ee:jndiName=OutstandingOrders,plugin=pool,service=EJB
    2004-06-04 08:16:24,271 INFO [org.jboss.ejb.StatelessSessionContainer] Started jboss.j2ee:jndiName=OutstandingOrders,service=EJB

    If your bean is deployed then you would get something like this on Server console for your EJB. Check out that...for your Bean. Ignore my Bean name !!

    My guess would be there is problem in the deployment descriptor defining the CMP fields with DD columns. Check that as well to make sure that all the field mappings including primary key are correct in the deployment descriptor.
    And also becasue you have defined localhost in the context look-up, I belive the server running locally ?.
  10. JBoss Initial Context[ Go to top ]

    There is an error in your parameters for JBoss Initial Context.
    properties.setProperty("java.naming.factory.url.pkgs", "org.jnp.interfaces.NamingContextFactory");
    Value for "java.naming.factory.url.pkgs" should be defined as "org.jboss.naming:org.jnp.interfaces".
    As for me I use "jndi.properties" file for getting Initial Context. This way is much easier and portable.
  11. JBoss Initial Context[ Go to top ]

    Ummmmm..... I thought the URL to your naming perovider should start with jnp. Am I smoking something? jnp://localhost:1099 shound't it look like this????
  12. JBoss Initial Context[ Go to top ]

    OK Arun Nair, thanks for answer, I saw in the JBoss console and I find something the same
    that appears for your bean:

    10:20:39,411 INFO [EjbModule] Deploying ApasSocio
    10:20:40,726 INFO [ApasSocio] Table 'APAS_SOCIO' already exists
    10:20:40,868 INFO [EntityInstancePool] Started jboss.j2ee:jndiName=apas.ApasSoc
    10:20:40,868 INFO [EntityContainer] Started jboss.j2ee:jndiName=apas.ApasSocioR
    10:20:40,868 INFO [EjbModule] Started jboss.j2ee:module=ModuleAPAS.jar,service=
    10:20:40,868 INFO [EJBDeployer] Deployed: file:/C:/jboss-3.2.3/server/default/d

    Its ok??

    Ok Vyacheslav Zakovyrya thanks for answer, I will make that properties file, its better you
    are Right, I modify the properties like this

          properties.setProperty("java.naming.provider.url", "jnp://localhost:1099");

    I also make the change that Udayan Patel (thanks for answer), ant put jnp instead http

    With all this change I get a new error:

    javax.naming.NameNotFoundException: apas.ApasSocioRemote not bound On a try catch of my application
    it seem that in the console I don't get any error. apas.ApasSocioRemote its the home JNDI name of my EJB

    and I make references to it in this way:

          Object homeObject = context.lookup("apas.ApasSocioRemote");

    Regards Daniel
  13. JBoss Initial Context[ Go to top ]

    I forget to say I'm connecting to a SQL server:

    I create this xml for the DataSource: (I name it "mssql.xml" it's that ok?, I put it on the directory: C:\Program Files\jboss-3.2.3\server\default\deploy, and I delete hsqldb-ds.xml It's that Ok?) :

    <?xml version="1.0" encoding="UTF-8"?>

    With this I received this error on the console:

     Depends On Me: , ObjectName: jboss.j2ee:jndiName=apas.ApasSocioRemote,service=E
     state: FAILED
     I Depend On:
     Depends On Me: org.jboss.deployment.DeploymentException: Error: can't find data
     source: java:/DefaultDS; - nested throwable: (javax.naming.NameNotFoundExceptio
    n: DefaultDS not bound)]

    Please help me, I'm new on JBoss but I want to learn to use it, thanks.
  14. JBoss Initial Context[ Go to top ]

    1. 'jndi.properties' file should be in your classpath. In this case body your method will be looking as:
    private Context getInitialContext() throws NamingException {
    return new InitialContext(); // this is simple, right? :)

    2. Just try to use my 'jndi.properties'. Change only name of host (localhost) if you need it.
    3. If you don't know exactly what classes to use for support JBoss, make sure that all *.jar files from %JBOSS_HOME%\client\lib\ are also in classpath for your client app.
    4. It's ok that you deleted 'hsqldb-ds.xml' but you left JBoss without default DataSource :). You can fix it in this way:
    Name of your 'mssql.xml' should be ended with '-ds.xml'. Something like 'mssql-ds.xml'. JBoss recognizes this file as deployer that contains info about DataSource. Look into %JBOSS_HOME%\docs\examples\jca\ and find 'mssql-ds.xml' - this is an example for you. If you need to register MS SQL as DEFAULT DataSource in JNDI, make sure that following line exists:
    Copy model mssql-ds.xml, change it for compliance with your needs, and put it into %JBOSS_HOME%\server\default\deploy\.
    5. Copy JDBC drivers for MS SQL into %JBOSS_HOME%\server\default\lib\. As far as I remember that should be 3 *.jar files.
    6. Have fun :)
  15. I'm really not sure about this naming convention...
    Name of your 'mssql.xml' should be ended with '-ds.xml'. Something like 'mssql-ds.xml'. JBoss recognizes this file as deployer that contains info about DataSource.
    but... Heh, whatever! :)