I've had trouble with lookups from web componenets to the comp/env space if
I don't have a jboss-web.xml file included in my WEB-INF directory. Try in
cluding an "empty" jboss-web.xml file, like this:

<?xml version="1.0"?>
<jboss-web/>

I included one, and my lookups suddenly worked.  (see a post I
dyslexically named "env-entry JDNI name")

Mike

On (11/05/01 06:38), David Ward wrote:
> Hi all,
> 
> I'm having a problem where my JSP can't find my ejb
> when in the java:comp/env namespace in JBoss.
> 
> In using the pre-configured/bundled
> JBoss-2.2.1_Tomcat-3.2.1 on RedHat Linux 7.0 (intel),
> JDK 1.3.0_02, and my EAR I created using the
> deploytool deploys fine on j2eesdk1.2.1.  It's a
> simple app: a jsp looks up a stateless session ejb
> which looks up a DataSource pointing at Oracle 8i.  I
> followed the online docs to the "T" to set up the
> OracleDS.
> 
> I've included the pertinant files, but basically, it
> doesn't
> look like the jsp can find the ejb when I reference it
> with java:comp/env/...  If I change my references back
> to not use java:comp/env/, it works on jboss but not
> on j2eesdk.  How can an EAR be completely J2EE
> portable when this happens?  Any suggestions?
> 
> Also, another problem I'm having though is
> that (when I change my code so it can find the ejb) my
> ejb can't seem to find the datasource, though
> it can in the j2eesdk.  Is there something wrong with
> my jboss.xml file?
> 
> Thanks for any help (and sorry for the long include
> below)...
> David
> 
> ================================================================================
> || index.jsp
> 
> <%!
>     private UserAuthority auth = null;
>     public void jspInit() {
>         try {
>             InitialContext ctx = new InitialContext();
>             Object ref =
> ctx.lookup("java:comp/env/ejb/UserAuthority");
>             UserAuthorityHome home =
> (UserAuthorityHome)PortableRemoteObject.narrow(ref,
> UserAuthorityHome.class);
>             auth = home.create();
>         } catch (Exception e) {
>             e.printStackTrace();
>         }
>     }
>     public void jspDestroy() {
>         auth = null;
>     }
> %>  
> ================================================================================
> || UserAuthorityBean.java
> 
>     private void openConnection()
>         throws NamingException, SQLException
>     {
>         InitialContext ctx = new InitialContext();
>         DataSource ds =
> (DataSource)ctx.lookup("java:comp/env/jdbc/database");
>         mConnection = ds.getConnection();
>     }
> 
> 
> ================================================================================
> || application.xml
> 
> <?xml version="1.0" encoding="ISO8859_1"?>
> <!DOCTYPE application PUBLIC '-//Sun Microsystems,
> Inc.//DTD J2EE Application 1.2//EN'
> 'http://java.sun.com/j2ee/dtds/application_1_2.dtd'>
> <application>
>   <display-name>UserTest</display-name>
>   <description>Application description</description>
>   <module>
>     <web>
>       <web-uri>war-ic.war</web-uri>
>       <context-root>user</context-root>
>     </web>
>   </module>
>   <module>
>     <ejb>ejb-jar-ic.jar</ejb>
>   </module>
> </application>   
> 
> ================================================================================
> || web.xml
> 
> <?xml version="1.0" encoding="ISO8859_1"?>
> <!DOCTYPE web-app PUBLIC '-//Sun Microsystems,
> Inc.//DTD Web Application 2.2//EN'
> 'http://java.sun.com/j2ee/dtds/web-app_2.2.dtd'>
> <web-app>
>   <display-name>UserTestWAR</display-name>
>   <description>no description</description>
>   <session-config>
>     <session-timeout>30</session-timeout>
>   </session-config>
>   <welcome-file-list>
>     <welcome-file>index.jsp</welcome-file>
>   </welcome-file-list>
>   <ejb-ref>
>     <description>no description</description>
>     <ejb-ref-name>ejb/UserAuthority</ejb-ref-name>
>     <ejb-ref-type>Session</ejb-ref-type>
>     <home>test.UserAuthorityHome</home>
>     <remote>test.UserAuthority</remote>
>   </ejb-ref>
> </web-app>   
> 
> ================================================================================
> || ejb-jar.xml
> 
> <?xml version="1.0" encoding="ISO8859_1"?>
> <!DOCTYPE ejb-jar PUBLIC '-//Sun Microsystems,
> Inc.//DTD Enterprise JavaBeans 1.1//EN'
> 'http://java.sun.com/j2ee/dtds/ejb-jar_1_1.dtd'>
> <ejb-jar>
>   <description>no description</description>
>   <display-name>UserAuthorityJAR</display-name>
>   <enterprise-beans>
>     <session>
>       <description>no description</description>
>       <display-name>UserAuthority</display-name>
>       <ejb-name>UserAuthority</ejb-name>
>       <home>test.UserAuthorityHome</home>
>       <remote>test.UserAuthority</remote>
>       <ejb-class>test.UserAuthorityBean</ejb-class>
>       <session-type>Stateless</session-type>
>       <transaction-type>Bean</transaction-type>
>       <resource-ref>
>         <res-ref-name>jdbc/database</res-ref-name>
>         <res-type>javax.sql.DataSource</res-type>
>         <res-auth>Container</res-auth>
>       </resource-ref>
>     </session>
>   </enterprise-beans>
> </ejb-jar>   
> 
> ================================================================================
> || jboss.xml
> 
> <jboss>
>   <enterprise-beans>
>     <session>
>       <ejb-name>UserAuthority</ejb-name>
>       <jndi-name>ejb/UserAuthority</jndi-name>
>       <resource-ref>
>         <res-ref-name>jdbc/database</res-ref-name>
>         <resource-name>OracleDS</resource-name>
>       </resource-ref
>     </session>
>   </enterprise-beans>
> </jboss>
>  
> ================================================================================
> || JBoss Output
> 
> [david@trinle bin]$ ./run_with_tomcat.sh
> JBOSS_CLASSPATH=:/usr/java/jdk1.3.0_02/lib/tools.jar:run.jar:../lib/crimson.jar
> jboss.home = /usr/local/JBoss-2.2.1_Tomcat-3.2.1/jboss
> Using configuration "tomcat"
> [Info] Java version: 1.3.0_02,Sun Microsystems Inc.
> [Info] Java VM: Java HotSpot(TM) Server VM
> 1.3.0_02,Sun Microsystems Inc.
> [Info] System: Linux 2.2.16-22,i386
> [Shutdown] Shutdown hook added
> [Service Control] Registered with server
> [Service Control] Initializing 26 MBeans
> [Webserver] Initializing
> [Webserver] Initialized
> [Naming] Initializing
> [Naming] Initialized
> [JNDIView] Initializing
> [JNDIView] Initialized
> [Transaction manager] Initializing
> [Transaction manager] Initialized
> [JAAS Security Manager] Initializing
> [JAAS Security Manager] Initialized
> [JDBC provider] Initializing
> [JDBC provider] Loaded JDBC-driver:org.hsql.jdbcDriver
> [JDBC provider] Loaded
> JDBC-driver:org.enhydra.instantdb.jdbc.idbDriver
> [JDBC provider] Loaded
> JDBC-driver:oracle.jdbc.driver.OracleDriver
> [JDBC provider] Initialized
> [Hypersonic] Initializing
> [Hypersonic] Initialized
> [InstantDB] Initializing
> [InstantDB] Initialized
> [DefaultDS] Initializing
> [DefaultDS] Initialized
> [OracleDS] Initializing
> [OracleDS] Initialized
> [Container factory] Initializing
> [Container factory] Initialized
> [EmbeddedTomcat] Initializing
> [EmbeddedTomcat] Initialized
> [JBossMQ] Initializing
> [JBossMQ] Initialized
> [DefaultJMSProvider] Initializing
> [DefaultJMSProvider] Initialized
> [StdJMSPool] Initializing
> [StdJMSPool] Initialized
> [J2EE Deployer Default] Initializing
> [J2EE Deployer Default] Initialized
> [Auto deploy] Initializing
> [Auto deploy] Initialized
> [RARDeployer] Initializing
> [RARDeployer] Initialized
> [ConnectionManagerFactoryLoader] Initializing
> [MinervaNoTransCMFactory] Initialized
> [ConnectionManagerFactoryLoader] Initializing
> [MinervaSharedLocalCMFactory] Initialized
> [ConnectionManagerFactoryLoader] Initializing
> [MinervaXACMFactory] Initialized
> [ConnectionFactoryLoader] Initializing
> [BlackBoxDS] Initialized
> [JMX RMI Adaptor] Initializing
> [JMX RMI Adaptor] Initialized
> [JMX RMI Connector] Initializing
> [JMX RMI Connector] Initialized
> [Mail Service] Initializing
> [Mail Service] Initialized
> [Service Control] Initialized 26 services
> [Service Control] Starting 26 MBeans
> [Webserver] Starting
> [Webserver] Codebase set to http://trinle:8083/
> [Webserver] Started webserver on port 8083
> [Webserver] Started
> [Naming] Starting
> [Naming] Naming started on port 1099
> [Naming] Started
> [JNDIView] Starting
> [JNDIView] Started
> [Transaction manager] Starting
> [Transaction manager] Started
> [JAAS Security Manager] Starting
> [JAAS Security Manager] JAAS.startService,
> cachePolicy=null
> [JAAS Security Manager] JAAS.startService,
> SecurityProxyFactory=org.jboss.security.SubjectSecurityProxyFactory@275d39
> [JAAS Security Manager] Started
> [JDBC provider] Starting
> [JDBC provider] Started
> [Hypersonic] Starting
> [Hypersonic] Server 1.4 is running
> [Hypersonic] Database started
> [Hypersonic] Started
> [InstantDB] Starting
> [Hypersonic] Press [Ctrl]+[C] to abort
> [InstantDB] XA Connection pool InstantDB bound to
> java:/InstantDB
> Enhydra InstantDB - Version 3.26
> [InstantDB] The Initial Developer of the Original Code
> is Lutris Technologies
> Inc.
> Portions created by Lutris are Copyright (C) 1997-2001
> Lutris Technologies,
> Inc.
> All Rights Reserved.
> [InstantDB] Started
> [DefaultDS] Starting
> [DefaultDS] XA Connection pool DefaultDS bound to
> java:/DefaultDS
> [DefaultDS] Started
> [OracleDS] Starting
> [OracleDS] XA Connection pool OracleDS bound to
> java:/OracleDS
> [OracleDS] Started
> [Container factory] Starting
> [Container factory] Started
> [EmbeddedTomcat] Starting
> [EmbeddedTomcat] Starting EmbeddedTomcat....
> 2001-05-10 04:46:01 - ContextManager: Adding context
> Ctx( /examples )
> 2001-05-10 04:46:01 - ContextManager: Adding context
> Ctx( /admin )
> [EmbeddedTomcat] Starting tomcat. Check
> logs/tomcat.log for error messages 
> 2001-05-10 04:46:01 - ContextManager: Adding context
> Ctx(  )
> 2001-05-10 04:46:01 - ContextManager: Adding context
> Ctx( /test )
> 2001-05-10 04:46:07 - PoolTcpConnector: Starting
> HttpConnectionHandler on 8080
> [EmbeddedTomcat] OK
> [EmbeddedTomcat] Started
> [JBossMQ] Starting
> 2001-05-10 04:46:07 - PoolTcpConnector: Starting
> Ajp12ConnectionHandler on 8007
> [JBossMQ] Server Version 0.8 Started
> [JBossMQ] Started
> [DefaultJMSProvider] Starting
> [DefaultJMSProvider] JMS provider Adapter
> DefaultJMSProvider bound to
> java:/DefaultJMSProvider
> [DefaultJMSProvider] Started
> [StdJMSPool] Starting
> [StdJMSPool] JMS provider Adapter StdJMSPool bound to
> java:/StdJMSPool
> [StdJMSPool] Started
> [J2EE Deployer Default] Starting
> [J2EE Deployer Default] Cleaning up deployment
> directory
> [J2EE Deployer Default] Started
> [Auto deploy] Starting
> [Auto deploy] Watching
> /usr/local/JBoss-2.2.1_Tomcat-3.2.1/jboss/deploy
> [Auto deploy] Started
> [RARDeployer] Starting
> [RARDeployer] Started
> [MinervaNoTransCMFactory] Starting
> [MinervaNoTransCMFactory] Connection manager factory
> 'MinervaNoTransCMFactory
> bound to 'java:/MinervaNoTransCMFactory'
> [MinervaNoTransCMFactory] Started
> [MinervaSharedLocalCMFactory] Starting
> [MinervaSharedLocalCMFactory] Connection manager
> factory
> 'MinervaSharedLocalCMFactory bound to
> 'java:/MinervaSharedLocalCMFactory'
> [MinervaSharedLocalCMFactory] Started
> [MinervaXACMFactory] Starting
> [MinervaXACMFactory] Connection manager factory
> 'MinervaXACMFactory bound to
> 'java:/MinervaXACMFactory'
> [MinervaXACMFactory] Started
> [BlackBoxDS] Starting
> [BlackBoxDS] Started
> [JMX RMI Adaptor] Starting
> [JMX RMI Adaptor] Started
> [JMX RMI Connector] Starting
> [JMX RMI Connector] Started
> [Mail Service] Starting
> [Mail Service] DEBUG: not loading system providers in
> <java.home>/lib
> [Mail Service] DEBUG: not loading optional custom
> providers file:
> /META-INF/javamail.providers
> [Mail Service] DEBUG: successfully loaded default
> providers
> [Mail Service] 
> DEBUG: Tables of loaded providers
> [Mail Service] DEBUG: Providers Listed By Class Name:
> 
>{com.sun.mail.smtp.SMTPTransport=javax.mail.Provider[TRANSPORT,smtp,com.sun.mail.smtp.SMTPTransport,Sun
> Microsystems, Inc],
> 
>com.sun.mail.imap.IMAPStore=javax.mail.Provider[STORE,imap,com.sun.mail.imap.IMAPStore,Sun
> Microsystems, Inc],
> 
>com.sun.mail.pop3.POP3Store=javax.mail.Provider[STORE,pop3,com.sun.mail.pop3.POP3Store,Sun
> Microsystems, Inc]}
> [Mail Service] DEBUG: Providers Listed By Protocol:
> {imap=javax.mail.Provider[STORE,imap,com.sun.mail.imap.IMAPStore,Sun
> Microsystems, Inc],
> pop3=javax.mail.Provider[STORE,pop3,com.sun.mail.pop3.POP3Store,Sun
> Microsystems, Inc],
> smtp=javax.mail.Provider[TRANSPORT,smtp,com.sun.mail.smtp.SMTPTransport,Sun
> Microsystems, Inc]}
> [Mail Service] DEBUG: not loading optional address map
> file:
> /META-INF/javamail.address.map
> [Mail Service] Mail Service 'Mail' bound to java:/Mail
> [Mail Service] Started
> [Service Control] Started 26 services
> [Default] JBoss 2.2.1 Started in 0m:41s
> [Auto deploy] Auto deploy of
> file:/usr/local/JBoss-2.2.1_Tomcat-3.2.1/jboss/deploy/UserTest.ear
> [J2EE Deployer Default] Deploy J2EE application:
> file:/usr/local/JBoss-2.2.1_Tomcat-3.2.1/jboss/deploy/UserTest.ear
> [J2EE Deployer Default] Create application
> UserTest.ear
> [J2EE Deployer Default] inflate and install module
> war-ic.war
> [J2EE Deployer Default] install module ejb-jar-ic.jar
> [J2EE Deployer Default] add all ejb jar files to the
> common classpath
> [J2EE Deployer Default] Starting module war-ic.war
> 2001-05-10 04:46:24 - ContextManager: Adding context
> Ctx( /user )
> [Container factory]
> 
>Deploying:file:/usr/local/JBoss-2.2.1_Tomcat-3.2.1/jboss/tmp/deploy/Default/UserTest.ear
> [Verifier] Verifying
> 
>file:/usr/local/JBoss-2.2.1_Tomcat-3.2.1/jboss/tmp/deploy/Default/UserTest.ear/ejb1002.jar
> [Container factory] Deploying UserAuthority
> [Container factory] Deployed application:
> file:/usr/local/JBoss-2.2.1_Tomcat-3.2.1/jboss/tmp/deploy/Default/UserTest.ear
> [J2EE Deployer Default] J2EE application:
> file:/usr/local/JBoss-2.2.1_Tomcat-3.2.1/jboss/deploy/UserTest.ear
> is deployed.
> [EmbeddedTomcat] javax.naming.NameNotFoundException:
> env not bound
> [EmbeddedTomcat]        at
> org.jnp.server.NamingServer.getBinding(NamingServer.java:474)
> [EmbeddedTomcat]        at
> org.jnp.server.NamingServer.getBinding(NamingServer.java:482)
> [EmbeddedTomcat]        at
> org.jnp.server.NamingServer.getObject(NamingServer.java:488)
> [EmbeddedTomcat]        at
> org.jnp.server.NamingServer.lookup(NamingServer.java:254)
> [EmbeddedTomcat]        at
> org.jnp.interfaces.NamingContext.lookup(NamingContext.java:295)
> [EmbeddedTomcat]        at
> org.jnp.interfaces.NamingContext.lookup(NamingContext.java:403)
> [EmbeddedTomcat]        at
> org.jnp.interfaces.NamingContext.lookup(NamingContext.java:279)
> [EmbeddedTomcat]        at
> javax.naming.InitialContext.lookup(InitialContext.java:350)
> [EmbeddedTomcat]        at
> _0002findex_0002ejspindex_jsp_3.jspInit(_0002findex_0002ejspindex_jsp_3.java:29)
> [EmbeddedTomcat]        at
> org.apache.jasper.runtime.HttpJspBase.init(HttpJspBase.java:92)
> [EmbeddedTomcat]        at
> org.apache.jasper.servlet.JspServlet$JspServletWrapper.load(JspServlet.java:120)
> [EmbeddedTomcat]        at
> 
>org.apache.jasper.servlet.JspServlet$JspServletWrapper.loadIfNecessary(JspServlet.java:154)
> [EmbeddedTomcat]        at
> org.apache.jasper.servlet.JspServlet$JspServletWrapper.service(JspServlet.java:164)
> [EmbeddedTomcat]        at
> org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:318)
> [EmbeddedTomcat]        at
> org.apache.jasper.servlet.JspServlet.service(JspServlet.java:391)
> [EmbeddedTomcat]        at
> javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
> [EmbeddedTomcat]        at
> org.apache.tomcat.core.ServletWrapper.doService(ServletWrapper.java:404)
> [EmbeddedTomcat]        at
> org.apache.tomcat.core.Handler.service(Handler.java:286)
> [EmbeddedTomcat]        at
> org.apache.tomcat.core.ServletWrapper.service(ServletWrapper.java:372)
> [EmbeddedTomcat]        at
> org.apache.tomcat.core.ContextManager.internalService(ContextManager.java:797)
> [EmbeddedTomcat]        at
> org.apache.tomcat.core.ContextManager.service(ContextManager.java:743)
> [EmbeddedTomcat]        at
> 
>org.apache.tomcat.service.http.HttpConnectionHandler.processConnection(HttpConnectionHandler.java:210)
> [EmbeddedTomcat]        at
> org.apache.tomcat.service.TcpWorkerThread.runIt(PoolTcpEndpoint.java:416)
> [EmbeddedTomcat]        at
> org.apache.tomcat.util.ThreadPool$ControlRunnable.run(ThreadPool.java:498)
> [EmbeddedTomcat]        at
> java.lang.Thread.run(Thread.java:484)
> 
> 
> 
> __________________________________________________
> Do You Yahoo!?
> Yahoo! Auctions - buy the things you want at great prices
> http://auctions.yahoo.com/
> 
> _______________________________________________
> JBoss-user mailing list
> [EMAIL PROTECTED]
> http://lists.sourceforge.net/lists/listinfo/jboss-user

-- 
Mike Hoolehan
Sycamore Associates, Inc.
[EMAIL PROTECTED]
301.668.4681x103

_______________________________________________
JBoss-user mailing list
[EMAIL PROTECTED]
http://lists.sourceforge.net/lists/listinfo/jboss-user

Reply via email to