Results 1 to 2 of 2
  1. #1
    sjunejo is offline Member
    Join Date
    Aug 2010
    Rep Power

    Default Help: New to J2EE :(

    Hi guys,

    I am new to J2EE development and got a small utility (website) to be created which should be deployable on jBoss (for now) using Servlets.

    I have some knowledge of Web development and using that I have managed to create one small website and deplooyed on jBoss successfully. I can POST data successfully to the target and so far so good but jBhoss is already loaded with following resources;

    Resource Adaptor offering JNDI 'jca/xxConnectionFactory' using file called 'xxxxx-ra.rar' and 'xx-ds.xml' file. In 'xx-ds.xml' all the connection parameter to the Database server is defined like host, port, ....etc etc.

    Now my task is that on runtime user will enter 'connection pool (JNDI) as jca/xxConnectionFactory' on my small utlity and which I need to lookup, connect to it and send message via the resource adaptor which is offering the JNDI at first place within the Servlet.

    Can anyone here help me how and where to start...any good links on internet which give me basic knowledge of these things or code snippet. I tried following but got an exception;

    Java Code:
    Context env = null;
    	  env = (Context)new InitialContext().lookup("java:comp/env");
    	  Object homeRef = env.lookup(CxFactory);   // CxFactory is recieved from POST data 
    	  //close the InitialContext
    	  if (homeRef == null)
    		  throw new ServletException(CxFactory + " is an unknown JNDI object");
      catch (NamingException ne)
    	  catch (NamingException nex)
    	  throw new ServletException(ne);
    And I got following exception as soon as the Servlet loaded on jboss console;
    Java Code:
    14:43:20,931 ERROR [[AgentServlet]] Servlet.service() for servlet AgentServlet threw exception
            at javax.naming.NameImpl.<init>(Unknown Source)
            at javax.naming.CompoundName.<init>(Unknown Source)
            at org.jnp.interfaces.NamingParser.parse(
            at org.jnp.interfaces.NamingContext.lookup(
            at client.AgentServlet.doGet(
            at javax.servlet.http.HttpServlet.service(
            at javax.servlet.http.HttpServlet.service(
            at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(
            at org.apache.catalina.core.ApplicationFilterChain.doFilter(
            at org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(
            at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(
            at org.apache.catalina.core.ApplicationFilterChain.doFilter(
            at org.apache.catalina.core.StandardWrapperValve.invoke(
            at org.apache.catalina.core.StandardContextValve.invoke(
            at org.apache.catalina.core.StandardHostValve.invoke(
            at org.apache.catalina.valves.ErrorReportValve.invoke(
            at org.jboss.web.tomcat.service.jca.CachedConnectionValve.invoke(
            at org.apache.catalina.core.StandardEngineValve.invoke(
            at org.apache.catalina.connector.CoyoteAdapter.service(
            at org.apache.coyote.http11.Http11Processor.process(
            at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(
            at Source)
    Your help and suggestion will appreciated.




  2. #2
    Sno's Avatar
    Sno is offline Senior Member
    Join Date
    Apr 2010
    Rep Power


    I hate jboss...

    Have you tried running it in debug mode?

    here an example of my working jboss connection
    Java Code:
    public static Connection getOracleConnection() throws Exception
    		Connection con = null;
    		//Properties properties = System.getProperties();
    			// Obtain our environment naming context
    			Context initCtx = new InitialContext();
    			Context envCtx = (Context) initCtx.lookup("java:comp/env");
    			// Look up our data source
    			DataSource ds = (DataSource) envCtx.lookup("jndi/OracleDSInternal");
    			// this resource monitors the connection details
    			PrintWriter lw = new PrintWriter(System.out);
    			// Establish connection
    			con = ds.getConnection();
    		catch (Exception e) 
    			Utility.displayAndLogException("Utility.getOracleConnection() - " + e.getMessage(), e);
    		return con;
    :rolleyes: ~ Sno ~ :rolleyes:
    '-~ B.S. Computer Science ~-'

Similar Threads

  1. Migrate from PHP to J2EE
    By venky in forum Advanced Java
    Replies: 0
    Last Post: 06-01-2010, 09:24 PM
  2. Java J2ee 2 - 4 Exp
    By drvijayy2k2 in forum Jobs Offered
    Replies: 1
    Last Post: 10-26-2009, 09:53 PM
  3. Why to Use J2EE and Option for this.
    By mgrprasad90 in forum Enterprise JavaBeans (EJB)
    Replies: 1
    Last Post: 08-27-2008, 09:32 AM
  4. How to add JAR to EAR in eclipse J2EE
    By amorfis in forum Eclipse
    Replies: 1
    Last Post: 01-03-2008, 10:34 AM
  5. JAVA and J2EE
    By rgbosque in forum New To Java
    Replies: 9
    Last Post: 12-04-2007, 06:28 AM

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts