You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by Ziggy O <di...@gmail.com> on 2008/10/01 18:54:15 UTC

javax.naming.NamingException: Cannot create resource instance

Hi,

I am trying to connect to an oracle database but cant seem to get the jdbc
connection to work. I am developing the application on a Windows desktop and
transferring it onto a Unix box.

When i test it on the Windows environmnet it does manage to connect but if i
test it on unix then i get an error. My gut feeling is that the installation
on the unix environment is missing a library but i cant figure out what it
is.

Here is how i am trying to get the jndi connection.

[code]
String fullname;
        if (jndiPrefix != null && jndiPrefix.length() > 0)
            fullname = jndiPrefix + datasource;
        else
            fullname = datasource;

        // JNDI
        Context ctx = null;
        DataSource ds = null;
        Connection conn = null;

        try
        {
            ctx = new InitialContext();
            Context envContext  = (Context)ctx.lookup("java:/comp/env");
            if (ctx != null)
            {
                ds = (DataSource)envContext.lookup(fullname);
                if (ds != null)
                {
                    conn = ds.getConnection();
                }
            }
        }
[/code]

And here is the Configuration.

Context.xml (User and password modified)

[code]
  <Resource name="jdbc/theDb" auth="Container"
                      type="javax.sql.DataSource"
driverClassName="oracle.jdbc.driver.OracleDriver"
                      url="jdbc:oracle:thin:@localhost:1521:webdev"
                      username="webuser" password="webuser" maxActive="20"
maxIdle="10"
                      maxWait="-1"/>
[/code]

web.xml

[code]
    <resource-ref>
     <description>Oracle Datasource</description>
     <res-ref-name>jdbc/theDb</res-ref-name>
     <res-type>oracle.jdbc.pool.OracleDataSource</res-type>
     <res-auth>Container</res-auth>
    </resource-ref>

[/code]

And here is the stack trace of the error

[code]
javax.naming.NamingException: Cannot create resource instance
        at
org.apache.naming.factory.ResourceFactory.getObjectInstance(ResourceFactory.java:143)
        at javax.naming.spi.NamingManager.getObjectInstance(Unknown Source)
        at org.apache.naming.NamingContext.lookup(NamingContext.java:793)
        at org.apache.naming.NamingContext.lookup(NamingContext.java:140)
        at org.apache.naming.NamingContext.lookup(NamingContext.java:781)
        at org.apache.naming.NamingContext.lookup(NamingContext.java:153)
        at
com.bt.ccs21.util.DbConnection.getJNDIConnection(DbConnection.java:334)
        at
com.bt.ccs21.util.DbConnection.getJNDIConnection(DbConnection.java:256)
        at
com.bt.ccs21.util.DbConnection.getJRunConnection(DbConnection.java:286)
        at
com.bt.ccs21.presentation.events.admin.LogonActionPost.preAction(LogonActionPost.java:118)
        at
com.bt.ccs21.presentation.events.CCS21EventAction.execute(CCS21EventAction.java:29)
        at
org.apache.struts.chain.commands.servlet.ExecuteAction.execute(ExecuteAction.java:58)
        at
org.apache.struts.chain.commands.AbstractExecuteAction.execute(AbstractExecuteAction.java:67)
        at
org.apache.struts.chain.commands.ActionCommandBase.execute(ActionCommandBase.java:51)
        at
org.apache.commons.chain.impl.ChainBase.execute(ChainBase.java:190)
        at
org.apache.commons.chain.generic.LookupCommand.execute(LookupCommand.java:304)
        at
org.apache.commons.chain.impl.ChainBase.execute(ChainBase.java:190)
        at
org.apache.struts.chain.ComposableRequestProcessor.process(ComposableRequestProcessor.java:283)
        at
org.apache.struts.action.ActionServlet.process(ActionServlet.java:1913)
        at
org.apache.struts.action.ActionServlet.doPost(ActionServlet.java:462)
        at javax.servlet.http.HttpServlet.service(HttpServlet.java:710)
        at javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
        at
org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:269)
        at
org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:188)
        at
org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:210)
        at
org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:174)
        at
org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)
        at
org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:117)
        at
org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:108)
        at
org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:151)
        at
org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:870)
        at
org.apache.coyote.http11.Http11BaseProtocol$Http11ConnectionHandler.processConnection(Http11BaseProtocol.java:665)
        at
org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpoint.java:528)
        at
org.apache.tomcat.util.net.LeaderFollowerWorkerThread.runIt(LeaderFollowerWorkerThread.java:81)
        at
org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:685)
        at java.lang.Thread.run(Unknown Source)
"/tmp/crmsauth.log.20081001" 561 lines, 48080 characters
        at
org.apache.coyote.http11.Http11BaseProtocol$Http11ConnectionHandler.processConnection(Http11BaseProtocol.java:665)
        at
org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpoint.java:528)
        at
org.apache.tomcat.util.net.LeaderFollowerWorkerThread.runIt(LeaderFollowerWorkerThread.java:81)
        at
org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:685)
        at java.lang.Thread.run(Unknown Source)
[/code]

What i dont understand is why it works on the installation on the windows
environment but not in the Unix environment. I check all the libraries and
everything under common/lib is the same for both environments.

Thanks

Edited by: ziggy on Oct 1, 2008 3:48 PM

Edited by: ziggy on Oct 1, 2008 3:50 PM

Re: javax.naming.NamingException: Cannot create resource instance

Posted by Ziggy O <di...@gmail.com>.
I forgot to mention that i am using Tomcat 5.5 on both the windows and unix
environment.

Thanks.


On Wed, Oct 1, 2008 at 5:54 PM, Ziggy O <di...@gmail.com> wrote:

> Hi,
>
> I am trying to connect to an oracle database but cant seem to get the jdbc
> connection to work. I am developing the application on a Windows desktop and
> transferring it onto a Unix box.
>
> When i test it on the Windows environmnet it does manage to connect but if
> i test it on unix then i get an error. My gut feeling is that the
> installation on the unix environment is missing a library but i cant figure
> out what it is.
>
> Here is how i am trying to get the jndi connection.
>
> [code]
> String fullname;
>         if (jndiPrefix != null && jndiPrefix.length() > 0)
>             fullname = jndiPrefix + datasource;
>         else
>             fullname = datasource;
>
>         // JNDI
>         Context ctx = null;
>         DataSource ds = null;
>         Connection conn = null;
>
>         try
>         {
>             ctx = new InitialContext();
>             Context envContext  = (Context)ctx.lookup("java:/comp/env");
>             if (ctx != null)
>             {
>                 ds = (DataSource)envContext.lookup(fullname);
>                 if (ds != null)
>                 {
>                     conn = ds.getConnection();
>                 }
>             }
>         }
> [/code]
>
> And here is the Configuration.
>
> Context.xml (User and password modified)
>
> [code]
>   <Resource name="jdbc/theDb" auth="Container"
>                       type="javax.sql.DataSource"
> driverClassName="oracle.jdbc.driver.OracleDriver"
>                       url="jdbc:oracle:thin:@localhost:1521:webdev"
>                       username="webuser" password="webuser" maxActive="20"
> maxIdle="10"
>                       maxWait="-1"/>
> [/code]
>
> web.xml
>
> [code]
>     <resource-ref>
>      <description>Oracle Datasource</description>
>      <res-ref-name>jdbc/theDb</res-ref-name>
>      <res-type>oracle.jdbc.pool.OracleDataSource</res-type>
>      <res-auth>Container</res-auth>
>     </resource-ref>
>
> [/code]
>
> And here is the stack trace of the error
>
> [code]
> javax.naming.NamingException: Cannot create resource instance
>         at
> org.apache.naming.factory.ResourceFactory.getObjectInstance(ResourceFactory.java:143)
>         at javax.naming.spi.NamingManager.getObjectInstance(Unknown Source)
>         at org.apache.naming.NamingContext.lookup(NamingContext.java:793)
>         at org.apache.naming.NamingContext.lookup(NamingContext.java:140)
>         at org.apache.naming.NamingContext.lookup(NamingContext.java:781)
>         at org.apache.naming.NamingContext.lookup(NamingContext.java:153)
>         at
> com.bt.ccs21.util.DbConnection.getJNDIConnection(DbConnection.java:334)
>         at
> com.bt.ccs21.util.DbConnection.getJNDIConnection(DbConnection.java:256)
>         at
> com.bt.ccs21.util.DbConnection.getJRunConnection(DbConnection.java:286)
>         at
> com.bt.ccs21.presentation.events.admin.LogonActionPost.preAction(LogonActionPost.java:118)
>         at
> com.bt.ccs21.presentation.events.CCS21EventAction.execute(CCS21EventAction.java:29)
>         at
> org.apache.struts.chain.commands.servlet.ExecuteAction.execute(ExecuteAction.java:58)
>         at
> org.apache.struts.chain.commands.AbstractExecuteAction.execute(AbstractExecuteAction.java:67)
>         at
> org.apache.struts.chain.commands.ActionCommandBase.execute(ActionCommandBase.java:51)
>         at
> org.apache.commons.chain.impl.ChainBase.execute(ChainBase.java:190)
>         at
> org.apache.commons.chain.generic.LookupCommand.execute(LookupCommand.java:304)
>         at
> org.apache.commons.chain.impl.ChainBase.execute(ChainBase.java:190)
>         at
> org.apache.struts.chain.ComposableRequestProcessor.process(ComposableRequestProcessor.java:283)
>         at
> org.apache.struts.action.ActionServlet.process(ActionServlet.java:1913)
>         at
> org.apache.struts.action.ActionServlet.doPost(ActionServlet.java:462)
>         at javax.servlet.http.HttpServlet.service(HttpServlet.java:710)
>         at javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
>         at
> org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:269)
>         at
> org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:188)
>         at
> org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:210)
>         at
> org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:174)
>         at
> org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)
>         at
> org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:117)
>         at
> org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:108)
>         at
> org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:151)
>         at
> org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:870)
>         at
> org.apache.coyote.http11.Http11BaseProtocol$Http11ConnectionHandler.processConnection(Http11BaseProtocol.java:665)
>         at
> org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpoint.java:528)
>         at
> org.apache.tomcat.util.net.LeaderFollowerWorkerThread.runIt(LeaderFollowerWorkerThread.java:81)
>         at
> org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:685)
>         at java.lang.Thread.run(Unknown Source)
> "/tmp/crmsauth.log.20081001" 561 lines, 48080 characters
>         at
> org.apache.coyote.http11.Http11BaseProtocol$Http11ConnectionHandler.processConnection(Http11BaseProtocol.java:665)
>         at
> org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpoint.java:528)
>         at
> org.apache.tomcat.util.net.LeaderFollowerWorkerThread.runIt(LeaderFollowerWorkerThread.java:81)
>         at
> org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:685)
>         at java.lang.Thread.run(Unknown Source)
> [/code]
>
> What i dont understand is why it works on the installation on the windows
> environment but not in the Unix environment. I check all the libraries and
> everything under common/lib is the same for both environments.
>
> Thanks
>
> Edited by: ziggy on Oct 1, 2008 3:48 PM
>
> Edited by: ziggy on Oct 1, 2008 3:50 PM
>

RE: javax.naming.NamingException: Cannot create resource instance

Posted by "Caldarale, Charles R" <Ch...@unisys.com>.
> From: Ziggy O [mailto:dini25@gmail.com]
> Subject: Re: javax.naming.NamingException: Cannot create
> resource instance
>
> One thing i have noticed is that if i take the
> /META-INF/Context.xml file and copy it into
> $CATALINA_HOME/conf/Catalina/localhost/testapp.xml
> it does work.

If the file is really named "Context.xml" it won't work; it must be "context.xml" (case matters).  Also, if you already have a conf/Catalina/localhost/testapp.xml file lying around from a previous deployment, that will override anything in the webapp's META-INF/context.xml file.  A proper undeployment of a webapp will delete its entry in the conf/Catalina/[host] directory.

 - Chuck


THIS COMMUNICATION MAY CONTAIN CONFIDENTIAL AND/OR OTHERWISE PROPRIETARY MATERIAL and is thus for use only by the intended recipient. If you received this in error, please contact the sender and delete the e-mail and its attachments from all computers.

---------------------------------------------------------------------
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Re: javax.naming.NamingException: Cannot create resource instance

Posted by Ziggy O <di...@gmail.com>.
Yes it looks like that fact it is named with uppercase C was the problem. I
renamed it to context.xml and it finally worked.

Thank you all for your help.



On Thu, Oct 2, 2008 at 5:59 PM, David Smith <dn...@cornell.edu> wrote:

> We have a winner!
> The Windows file system is one of the few (the only one I can think of)
> that's not case sensitive.  Unix, linux, bsd, macos, etc. , ... are all case
> sensitive.  You should change the file name 'Context.xml' to 'context.xml'
> and check to be sure it stays that way as you build your .war file.  After
> that you won't need to have testapp.xml in conf/Catalina/localhost.  Also
> you might want to check all the places in your webapp that references a file
> and be sure the names match in case to what's on disk.
>
>
> --David
>
> Ziggy O wrote:
>
>> Hi,
>>
>> The tomcat version on my Desktop is 5.5.27 and the Tomcat version on the
>> Unix environment is 5.5.23. Could the above minor version difference
>> cause
>> it?
>>
>> One thing i have noticed is that if i take the /META-INF/Context.xml file
>> and copy it into $CATALINA_HOME/conf/Catalina/localhost/testapp.xml it
>> does
>> work.
>>
>> i.e. why does it require the context file in that directory and why does
>> it
>> have to be renamed to my applications context. On the Windows environment
>> i
>> dont have to rename and copy the context file to
>> $CATALINA_HOME/conf/Catalina/localhost
>>
>> Thanks
>>
>>
>>
>> On Thu, Oct 2, 2008 at 12:55 PM, David Smith <dn...@cornell.edu> wrote:
>>
>>
>>
>>> Ok...
>>>
>>> 1) I don't see a tomcat version, could you post that?
>>> 2) Are you sure the tomcat version on the production environment the same
>>> as your dev system?
>>> 3) This is probably not causing the immediate problem, but <res-type> ...
>>> </res-type> in your web.xml should be javax.sql.Datasource, not
>>> oracle.jdbc.pool.OracleDataSource.
>>>
>>> --David
>>>
>>>
>>> Ziggy O wrote:
>>>
>>>
>>>
>>>> No mate that was the full stack trace.
>>>>
>>>> Thanks
>>>>
>>>>
>>>> On Wed, Oct 1, 2008 at 7:02 PM, David Smith <dn...@cornell.edu> wrote:
>>>>
>>>>
>>>>
>>>>
>>>>
>>>>> Seems like such a generic error would have a root cause.  Was there
>>>>> anything more to the stack trace?
>>>>>
>>>>> --David
>>>>>
>>>>>
>>>>> Ziggy O wrote:
>>>>>
>>>>>
>>>>>
>>>>>
>>>>>
>>>>>> Hi,
>>>>>>
>>>>>> I am trying to connect to an oracle database but cant seem to get the
>>>>>> jdbc
>>>>>> connection to work. I am developing the application on a Windows
>>>>>> desktop
>>>>>> and
>>>>>> transferring it onto a Unix box.
>>>>>>
>>>>>> When i test it on the Windows environmnet it does manage to connect
>>>>>> but
>>>>>> if
>>>>>> i
>>>>>> test it on unix then i get an error. My gut feeling is that the
>>>>>> installation
>>>>>> on the unix environment is missing a library but i cant figure out
>>>>>> what
>>>>>> it
>>>>>> is.
>>>>>>
>>>>>> Here is how i am trying to get the jndi connection.
>>>>>>
>>>>>> [code]
>>>>>> String fullname;
>>>>>>      if (jndiPrefix != null && jndiPrefix.length() > 0)
>>>>>>          fullname = jndiPrefix + datasource;
>>>>>>      else
>>>>>>          fullname = datasource;
>>>>>>
>>>>>>      // JNDI
>>>>>>      Context ctx = null;
>>>>>>      DataSource ds = null;
>>>>>>      Connection conn = null;
>>>>>>
>>>>>>      try
>>>>>>      {
>>>>>>          ctx = new InitialContext();
>>>>>>          Context envContext  = (Context)ctx.lookup("java:/comp/env");
>>>>>>          if (ctx != null)
>>>>>>          {
>>>>>>              ds = (DataSource)envContext.lookup(fullname);
>>>>>>              if (ds != null)
>>>>>>              {
>>>>>>                  conn = ds.getConnection();
>>>>>>              }
>>>>>>          }
>>>>>>      }
>>>>>> [/code]
>>>>>>
>>>>>> And here is the Configuration.
>>>>>>
>>>>>> Context.xml (User and password modified)
>>>>>>
>>>>>> [code]
>>>>>>  <Resource name="jdbc/theDb" auth="Container"
>>>>>>                    type="javax.sql.DataSource"
>>>>>> driverClassName="oracle.jdbc.driver.OracleDriver"
>>>>>>                    url="jdbc:oracle:thin:@localhost:1521:webdev"
>>>>>>                    username="webuser" password="webuser"
>>>>>> maxActive="20"
>>>>>> maxIdle="10"
>>>>>>                    maxWait="-1"/>
>>>>>> [/code]
>>>>>>
>>>>>> web.xml
>>>>>>
>>>>>> [code]
>>>>>>  <resource-ref>
>>>>>>   <description>Oracle Datasource</description>
>>>>>>   <res-ref-name>jdbc/theDb</res-ref-name>
>>>>>>   <res-type>oracle.jdbc.pool.OracleDataSource</res-type>
>>>>>>   <res-auth>Container</res-auth>
>>>>>>  </resource-ref>
>>>>>>
>>>>>> [/code]
>>>>>>
>>>>>> And here is the stack trace of the error
>>>>>>
>>>>>> [code]
>>>>>> javax.naming.NamingException: Cannot create resource instance
>>>>>>      at
>>>>>>
>>>>>>
>>>>>>
>>>>>> org.apache.naming.factory.ResourceFactory.getObjectInstance(ResourceFactory.java:143)
>>>>>>      at javax.naming.spi.NamingManager.getObjectInstance(Unknown
>>>>>> Source)
>>>>>>      at org.apache.naming.NamingContext.lookup(NamingContext.java:793)
>>>>>>      at org.apache.naming.NamingContext.lookup(NamingContext.java:140)
>>>>>>      at org.apache.naming.NamingContext.lookup(NamingContext.java:781)
>>>>>>      at org.apache.naming.NamingContext.lookup(NamingContext.java:153)
>>>>>>      at
>>>>>>
>>>>>> com.bt.ccs21.util.DbConnection.getJNDIConnection(DbConnection.java:334)
>>>>>>      at
>>>>>>
>>>>>> com.bt.ccs21.util.DbConnection.getJNDIConnection(DbConnection.java:256)
>>>>>>      at
>>>>>>
>>>>>> com.bt.ccs21.util.DbConnection.getJRunConnection(DbConnection.java:286)
>>>>>>      at
>>>>>>
>>>>>>
>>>>>>
>>>>>> com.bt.ccs21.presentation.events.admin.LogonActionPost.preAction(LogonActionPost.java:118)
>>>>>>      at
>>>>>>
>>>>>>
>>>>>>
>>>>>> com.bt.ccs21.presentation.events.CCS21EventAction.execute(CCS21EventAction.java:29)
>>>>>>      at
>>>>>>
>>>>>>
>>>>>>
>>>>>> org.apache.struts.chain.commands.servlet.ExecuteAction.execute(ExecuteAction.java:58)
>>>>>>      at
>>>>>>
>>>>>>
>>>>>>
>>>>>> org.apache.struts.chain.commands.AbstractExecuteAction.execute(AbstractExecuteAction.java:67)
>>>>>>      at
>>>>>>
>>>>>>
>>>>>>
>>>>>> org.apache.struts.chain.commands.ActionCommandBase.execute(ActionCommandBase.java:51)
>>>>>>      at
>>>>>> org.apache.commons.chain.impl.ChainBase.execute(ChainBase.java:190)
>>>>>>      at
>>>>>>
>>>>>>
>>>>>>
>>>>>> org.apache.commons.chain.generic.LookupCommand.execute(LookupCommand.java:304)
>>>>>>      at
>>>>>> org.apache.commons.chain.impl.ChainBase.execute(ChainBase.java:190)
>>>>>>      at
>>>>>>
>>>>>>
>>>>>>
>>>>>> org.apache.struts.chain.ComposableRequestProcessor.process(ComposableRequestProcessor.java:283)
>>>>>>      at
>>>>>>
>>>>>> org.apache.struts.action.ActionServlet.process(ActionServlet.java:1913)
>>>>>>      at
>>>>>> org.apache.struts.action.ActionServlet.doPost(ActionServlet.java:462)
>>>>>>      at javax.servlet.http.HttpServlet.service(HttpServlet.java:710)
>>>>>>      at javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
>>>>>>      at
>>>>>>
>>>>>>
>>>>>>
>>>>>> org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:269)
>>>>>>      at
>>>>>>
>>>>>>
>>>>>>
>>>>>> org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:188)
>>>>>>      at
>>>>>>
>>>>>>
>>>>>>
>>>>>> org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:210)
>>>>>>      at
>>>>>>
>>>>>>
>>>>>>
>>>>>> org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:174)
>>>>>>      at
>>>>>>
>>>>>>
>>>>>>
>>>>>> org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)
>>>>>>      at
>>>>>>
>>>>>>
>>>>>>
>>>>>> org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:117)
>>>>>>      at
>>>>>>
>>>>>>
>>>>>>
>>>>>> org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:108)
>>>>>>      at
>>>>>>
>>>>>>
>>>>>>
>>>>>> org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:151)
>>>>>>      at
>>>>>>
>>>>>>
>>>>>> org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:870)
>>>>>>      at
>>>>>>
>>>>>>
>>>>>>
>>>>>> org.apache.coyote.http11.Http11BaseProtocol$Http11ConnectionHandler.processConnection(Http11BaseProtocol.java:665)
>>>>>>      at
>>>>>>
>>>>>>
>>>>>>
>>>>>> org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpoint.java:528)
>>>>>>      at
>>>>>>
>>>>>>
>>>>>>
>>>>>> org.apache.tomcat.util.net.LeaderFollowerWorkerThread.runIt(LeaderFollowerWorkerThread.java:81)
>>>>>>      at
>>>>>>
>>>>>>
>>>>>>
>>>>>> org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:685)
>>>>>>      at java.lang.Thread.run(Unknown Source)
>>>>>> "/tmp/crmsauth.log.20081001" 561 lines, 48080 characters
>>>>>>      at
>>>>>>
>>>>>>
>>>>>>
>>>>>> org.apache.coyote.http11.Http11BaseProtocol$Http11ConnectionHandler.processConnection(Http11BaseProtocol.java:665)
>>>>>>      at
>>>>>>
>>>>>>
>>>>>>
>>>>>> org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpoint.java:528)
>>>>>>      at
>>>>>>
>>>>>>
>>>>>>
>>>>>> org.apache.tomcat.util.net.LeaderFollowerWorkerThread.runIt(LeaderFollowerWorkerThread.java:81)
>>>>>>      at
>>>>>>
>>>>>>
>>>>>>
>>>>>> org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:685)
>>>>>>      at java.lang.Thread.run(Unknown Source)
>>>>>> [/code]
>>>>>>
>>>>>> What i dont understand is why it works on the installation on the
>>>>>> windows
>>>>>> environment but not in the Unix environment. I check all the libraries
>>>>>> and
>>>>>> everything under common/lib is the same for both environments.
>>>>>>
>>>>>> Thanks
>>>>>>
>>>>>> Edited by: ziggy on Oct 1, 2008 3:48 PM
>>>>>>
>>>>>> Edited by: ziggy on Oct 1, 2008 3:50 PM
>>>>>>
>>>>>>
>>>>>>
>>>>>>
>>>>>>
>>>>>>
>>>>>>
>>>>> ---------------------------------------------------------------------
>>>>> To start a new topic, e-mail: users@tomcat.apache.org
>>>>> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
>>>>> For additional commands, e-mail: users-help@tomcat.apache.org
>>>>>
>>>>>
>>>>>
>>>>>
>>>>>
>>>>>
>>>>
>>>>
>>>>
>>> ---------------------------------------------------------------------
>>> To start a new topic, e-mail: users@tomcat.apache.org
>>> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
>>> For additional commands, e-mail: users-help@tomcat.apache.org
>>>
>>>
>>>
>>>
>>
>>
>>
>
>
> ---------------------------------------------------------------------
> To start a new topic, e-mail: users@tomcat.apache.org
> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
> For additional commands, e-mail: users-help@tomcat.apache.org
>
>

Re: javax.naming.NamingException: Cannot create resource instance

Posted by David Smith <dn...@cornell.edu>.
We have a winner! 

The Windows file system is one of the few (the only one I can think of) 
that's not case sensitive.  Unix, linux, bsd, macos, etc. , ... are all 
case sensitive.  You should change the file name 'Context.xml' to 
'context.xml' and check to be sure it stays that way as you build your 
.war file.  After that you won't need to have testapp.xml in 
conf/Catalina/localhost.  Also you might want to check all the places in 
your webapp that references a file and be sure the names match in case 
to what's on disk.

--David

Ziggy O wrote:
> Hi,
>
> The tomcat version on my Desktop is 5.5.27 and the Tomcat version on the
> Unix environment is 5.5.23. Could the above minor version difference cause
> it?
>
> One thing i have noticed is that if i take the /META-INF/Context.xml file
> and copy it into $CATALINA_HOME/conf/Catalina/localhost/testapp.xml it does
> work.
>
> i.e. why does it require the context file in that directory and why does it
> have to be renamed to my applications context. On the Windows environment i
> dont have to rename and copy the context file to
> $CATALINA_HOME/conf/Catalina/localhost
>
> Thanks
>
>
>
> On Thu, Oct 2, 2008 at 12:55 PM, David Smith <dn...@cornell.edu> wrote:
>
>   
>> Ok...
>>
>> 1) I don't see a tomcat version, could you post that?
>> 2) Are you sure the tomcat version on the production environment the same
>> as your dev system?
>> 3) This is probably not causing the immediate problem, but <res-type> ...
>> </res-type> in your web.xml should be javax.sql.Datasource, not
>> oracle.jdbc.pool.OracleDataSource.
>>
>> --David
>>
>>
>> Ziggy O wrote:
>>
>>     
>>> No mate that was the full stack trace.
>>>
>>> Thanks
>>>
>>>
>>> On Wed, Oct 1, 2008 at 7:02 PM, David Smith <dn...@cornell.edu> wrote:
>>>
>>>
>>>
>>>       
>>>> Seems like such a generic error would have a root cause.  Was there
>>>> anything more to the stack trace?
>>>>
>>>> --David
>>>>
>>>>
>>>> Ziggy O wrote:
>>>>
>>>>
>>>>
>>>>         
>>>>> Hi,
>>>>>
>>>>> I am trying to connect to an oracle database but cant seem to get the
>>>>> jdbc
>>>>> connection to work. I am developing the application on a Windows desktop
>>>>> and
>>>>> transferring it onto a Unix box.
>>>>>
>>>>> When i test it on the Windows environmnet it does manage to connect but
>>>>> if
>>>>> i
>>>>> test it on unix then i get an error. My gut feeling is that the
>>>>> installation
>>>>> on the unix environment is missing a library but i cant figure out what
>>>>> it
>>>>> is.
>>>>>
>>>>> Here is how i am trying to get the jndi connection.
>>>>>
>>>>> [code]
>>>>> String fullname;
>>>>>       if (jndiPrefix != null && jndiPrefix.length() > 0)
>>>>>           fullname = jndiPrefix + datasource;
>>>>>       else
>>>>>           fullname = datasource;
>>>>>
>>>>>       // JNDI
>>>>>       Context ctx = null;
>>>>>       DataSource ds = null;
>>>>>       Connection conn = null;
>>>>>
>>>>>       try
>>>>>       {
>>>>>           ctx = new InitialContext();
>>>>>           Context envContext  = (Context)ctx.lookup("java:/comp/env");
>>>>>           if (ctx != null)
>>>>>           {
>>>>>               ds = (DataSource)envContext.lookup(fullname);
>>>>>               if (ds != null)
>>>>>               {
>>>>>                   conn = ds.getConnection();
>>>>>               }
>>>>>           }
>>>>>       }
>>>>> [/code]
>>>>>
>>>>> And here is the Configuration.
>>>>>
>>>>> Context.xml (User and password modified)
>>>>>
>>>>> [code]
>>>>>  <Resource name="jdbc/theDb" auth="Container"
>>>>>                     type="javax.sql.DataSource"
>>>>> driverClassName="oracle.jdbc.driver.OracleDriver"
>>>>>                     url="jdbc:oracle:thin:@localhost:1521:webdev"
>>>>>                     username="webuser" password="webuser" maxActive="20"
>>>>> maxIdle="10"
>>>>>                     maxWait="-1"/>
>>>>> [/code]
>>>>>
>>>>> web.xml
>>>>>
>>>>> [code]
>>>>>   <resource-ref>
>>>>>    <description>Oracle Datasource</description>
>>>>>    <res-ref-name>jdbc/theDb</res-ref-name>
>>>>>    <res-type>oracle.jdbc.pool.OracleDataSource</res-type>
>>>>>    <res-auth>Container</res-auth>
>>>>>   </resource-ref>
>>>>>
>>>>> [/code]
>>>>>
>>>>> And here is the stack trace of the error
>>>>>
>>>>> [code]
>>>>> javax.naming.NamingException: Cannot create resource instance
>>>>>       at
>>>>>
>>>>>
>>>>> org.apache.naming.factory.ResourceFactory.getObjectInstance(ResourceFactory.java:143)
>>>>>       at javax.naming.spi.NamingManager.getObjectInstance(Unknown
>>>>> Source)
>>>>>       at org.apache.naming.NamingContext.lookup(NamingContext.java:793)
>>>>>       at org.apache.naming.NamingContext.lookup(NamingContext.java:140)
>>>>>       at org.apache.naming.NamingContext.lookup(NamingContext.java:781)
>>>>>       at org.apache.naming.NamingContext.lookup(NamingContext.java:153)
>>>>>       at
>>>>> com.bt.ccs21.util.DbConnection.getJNDIConnection(DbConnection.java:334)
>>>>>       at
>>>>> com.bt.ccs21.util.DbConnection.getJNDIConnection(DbConnection.java:256)
>>>>>       at
>>>>> com.bt.ccs21.util.DbConnection.getJRunConnection(DbConnection.java:286)
>>>>>       at
>>>>>
>>>>>
>>>>> com.bt.ccs21.presentation.events.admin.LogonActionPost.preAction(LogonActionPost.java:118)
>>>>>       at
>>>>>
>>>>>
>>>>> com.bt.ccs21.presentation.events.CCS21EventAction.execute(CCS21EventAction.java:29)
>>>>>       at
>>>>>
>>>>>
>>>>> org.apache.struts.chain.commands.servlet.ExecuteAction.execute(ExecuteAction.java:58)
>>>>>       at
>>>>>
>>>>>
>>>>> org.apache.struts.chain.commands.AbstractExecuteAction.execute(AbstractExecuteAction.java:67)
>>>>>       at
>>>>>
>>>>>
>>>>> org.apache.struts.chain.commands.ActionCommandBase.execute(ActionCommandBase.java:51)
>>>>>       at
>>>>> org.apache.commons.chain.impl.ChainBase.execute(ChainBase.java:190)
>>>>>       at
>>>>>
>>>>>
>>>>> org.apache.commons.chain.generic.LookupCommand.execute(LookupCommand.java:304)
>>>>>       at
>>>>> org.apache.commons.chain.impl.ChainBase.execute(ChainBase.java:190)
>>>>>       at
>>>>>
>>>>>
>>>>> org.apache.struts.chain.ComposableRequestProcessor.process(ComposableRequestProcessor.java:283)
>>>>>       at
>>>>> org.apache.struts.action.ActionServlet.process(ActionServlet.java:1913)
>>>>>       at
>>>>> org.apache.struts.action.ActionServlet.doPost(ActionServlet.java:462)
>>>>>       at javax.servlet.http.HttpServlet.service(HttpServlet.java:710)
>>>>>       at javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
>>>>>       at
>>>>>
>>>>>
>>>>> org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:269)
>>>>>       at
>>>>>
>>>>>
>>>>> org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:188)
>>>>>       at
>>>>>
>>>>>
>>>>> org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:210)
>>>>>       at
>>>>>
>>>>>
>>>>> org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:174)
>>>>>       at
>>>>>
>>>>>
>>>>> org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)
>>>>>       at
>>>>>
>>>>>
>>>>> org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:117)
>>>>>       at
>>>>>
>>>>>
>>>>> org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:108)
>>>>>       at
>>>>>
>>>>>
>>>>> org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:151)
>>>>>       at
>>>>>
>>>>> org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:870)
>>>>>       at
>>>>>
>>>>>
>>>>> org.apache.coyote.http11.Http11BaseProtocol$Http11ConnectionHandler.processConnection(Http11BaseProtocol.java:665)
>>>>>       at
>>>>>
>>>>>
>>>>> org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpoint.java:528)
>>>>>       at
>>>>>
>>>>>
>>>>> org.apache.tomcat.util.net.LeaderFollowerWorkerThread.runIt(LeaderFollowerWorkerThread.java:81)
>>>>>       at
>>>>>
>>>>>
>>>>> org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:685)
>>>>>       at java.lang.Thread.run(Unknown Source)
>>>>> "/tmp/crmsauth.log.20081001" 561 lines, 48080 characters
>>>>>       at
>>>>>
>>>>>
>>>>> org.apache.coyote.http11.Http11BaseProtocol$Http11ConnectionHandler.processConnection(Http11BaseProtocol.java:665)
>>>>>       at
>>>>>
>>>>>
>>>>> org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpoint.java:528)
>>>>>       at
>>>>>
>>>>>
>>>>> org.apache.tomcat.util.net.LeaderFollowerWorkerThread.runIt(LeaderFollowerWorkerThread.java:81)
>>>>>       at
>>>>>
>>>>>
>>>>> org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:685)
>>>>>       at java.lang.Thread.run(Unknown Source)
>>>>> [/code]
>>>>>
>>>>> What i dont understand is why it works on the installation on the
>>>>> windows
>>>>> environment but not in the Unix environment. I check all the libraries
>>>>> and
>>>>> everything under common/lib is the same for both environments.
>>>>>
>>>>> Thanks
>>>>>
>>>>> Edited by: ziggy on Oct 1, 2008 3:48 PM
>>>>>
>>>>> Edited by: ziggy on Oct 1, 2008 3:50 PM
>>>>>
>>>>>
>>>>>
>>>>>
>>>>>
>>>>>           
>>>> ---------------------------------------------------------------------
>>>> To start a new topic, e-mail: users@tomcat.apache.org
>>>> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
>>>> For additional commands, e-mail: users-help@tomcat.apache.org
>>>>
>>>>
>>>>
>>>>
>>>>         
>>>
>>>       
>> ---------------------------------------------------------------------
>> To start a new topic, e-mail: users@tomcat.apache.org
>> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
>> For additional commands, e-mail: users-help@tomcat.apache.org
>>
>>
>>     
>
>   


---------------------------------------------------------------------
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Re: javax.naming.NamingException: Cannot create resource instance

Posted by Ziggy O <di...@gmail.com>.
A bit more info which i think might be relevant.

When i run it on my desktop i ran it directly from within Netbeans but when
i run it on the Unix server i export the project as a war file (within
netbeans) and copy it into the webapps directory on the Unix environment.

Is it possible that netbeans is including some libraries that are not
available on the Unix environment when i run it on the desktop?


On Thu, Oct 2, 2008 at 1:48 PM, Ziggy O <di...@gmail.com> wrote:

> Hi,
>
> The tomcat version on my Desktop is 5.5.27 and the Tomcat version on the
> Unix environment is 5.5.23. Could the above minor version difference cause
> it?
>
> One thing i have noticed is that if i take the /META-INF/Context.xml file
> and copy it into $CATALINA_HOME/conf/Catalina/localhost/testapp.xml it does
> work.
>
> i.e. why does it require the context file in that directory and why does it
> have to be renamed to my applications context. On the Windows environment i
> dont have to rename and copy the context file to
> $CATALINA_HOME/conf/Catalina/localhost
>
> Thanks
>
>
>
>
> On Thu, Oct 2, 2008 at 12:55 PM, David Smith <dn...@cornell.edu> wrote:
>
>> Ok...
>>
>> 1) I don't see a tomcat version, could you post that?
>> 2) Are you sure the tomcat version on the production environment the same
>> as your dev system?
>> 3) This is probably not causing the immediate problem, but <res-type> ...
>> </res-type> in your web.xml should be javax.sql.Datasource, not
>> oracle.jdbc.pool.OracleDataSource.
>>
>> --David
>>
>>
>> Ziggy O wrote:
>>
>>> No mate that was the full stack trace.
>>>
>>> Thanks
>>>
>>>
>>> On Wed, Oct 1, 2008 at 7:02 PM, David Smith <dn...@cornell.edu> wrote:
>>>
>>>
>>>
>>>> Seems like such a generic error would have a root cause.  Was there
>>>> anything more to the stack trace?
>>>>
>>>> --David
>>>>
>>>>
>>>> Ziggy O wrote:
>>>>
>>>>
>>>>
>>>>> Hi,
>>>>>
>>>>> I am trying to connect to an oracle database but cant seem to get the
>>>>> jdbc
>>>>> connection to work. I am developing the application on a Windows
>>>>> desktop
>>>>> and
>>>>> transferring it onto a Unix box.
>>>>>
>>>>> When i test it on the Windows environmnet it does manage to connect but
>>>>> if
>>>>> i
>>>>> test it on unix then i get an error. My gut feeling is that the
>>>>> installation
>>>>> on the unix environment is missing a library but i cant figure out what
>>>>> it
>>>>> is.
>>>>>
>>>>> Here is how i am trying to get the jndi connection.
>>>>>
>>>>> [code]
>>>>> String fullname;
>>>>>       if (jndiPrefix != null && jndiPrefix.length() > 0)
>>>>>           fullname = jndiPrefix + datasource;
>>>>>       else
>>>>>           fullname = datasource;
>>>>>
>>>>>       // JNDI
>>>>>       Context ctx = null;
>>>>>       DataSource ds = null;
>>>>>       Connection conn = null;
>>>>>
>>>>>       try
>>>>>       {
>>>>>           ctx = new InitialContext();
>>>>>           Context envContext  = (Context)ctx.lookup("java:/comp/env");
>>>>>           if (ctx != null)
>>>>>           {
>>>>>               ds = (DataSource)envContext.lookup(fullname);
>>>>>               if (ds != null)
>>>>>               {
>>>>>                   conn = ds.getConnection();
>>>>>               }
>>>>>           }
>>>>>       }
>>>>> [/code]
>>>>>
>>>>> And here is the Configuration.
>>>>>
>>>>> Context.xml (User and password modified)
>>>>>
>>>>> [code]
>>>>>  <Resource name="jdbc/theDb" auth="Container"
>>>>>                     type="javax.sql.DataSource"
>>>>> driverClassName="oracle.jdbc.driver.OracleDriver"
>>>>>                     url="jdbc:oracle:thin:@localhost:1521:webdev"
>>>>>                     username="webuser" password="webuser"
>>>>> maxActive="20"
>>>>> maxIdle="10"
>>>>>                     maxWait="-1"/>
>>>>> [/code]
>>>>>
>>>>> web.xml
>>>>>
>>>>> [code]
>>>>>   <resource-ref>
>>>>>    <description>Oracle Datasource</description>
>>>>>    <res-ref-name>jdbc/theDb</res-ref-name>
>>>>>    <res-type>oracle.jdbc.pool.OracleDataSource</res-type>
>>>>>    <res-auth>Container</res-auth>
>>>>>   </resource-ref>
>>>>>
>>>>> [/code]
>>>>>
>>>>> And here is the stack trace of the error
>>>>>
>>>>> [code]
>>>>> javax.naming.NamingException: Cannot create resource instance
>>>>>       at
>>>>>
>>>>>
>>>>> org.apache.naming.factory.ResourceFactory.getObjectInstance(ResourceFactory.java:143)
>>>>>       at javax.naming.spi.NamingManager.getObjectInstance(Unknown
>>>>> Source)
>>>>>       at org.apache.naming.NamingContext.lookup(NamingContext.java:793)
>>>>>       at org.apache.naming.NamingContext.lookup(NamingContext.java:140)
>>>>>       at org.apache.naming.NamingContext.lookup(NamingContext.java:781)
>>>>>       at org.apache.naming.NamingContext.lookup(NamingContext.java:153)
>>>>>       at
>>>>> com.bt.ccs21.util.DbConnection.getJNDIConnection(DbConnection.java:334)
>>>>>       at
>>>>> com.bt.ccs21.util.DbConnection.getJNDIConnection(DbConnection.java:256)
>>>>>       at
>>>>> com.bt.ccs21.util.DbConnection.getJRunConnection(DbConnection.java:286)
>>>>>       at
>>>>>
>>>>>
>>>>> com.bt.ccs21.presentation.events.admin.LogonActionPost.preAction(LogonActionPost.java:118)
>>>>>       at
>>>>>
>>>>>
>>>>> com.bt.ccs21.presentation.events.CCS21EventAction.execute(CCS21EventAction.java:29)
>>>>>       at
>>>>>
>>>>>
>>>>> org.apache.struts.chain.commands.servlet.ExecuteAction.execute(ExecuteAction.java:58)
>>>>>       at
>>>>>
>>>>>
>>>>> org.apache.struts.chain.commands.AbstractExecuteAction.execute(AbstractExecuteAction.java:67)
>>>>>       at
>>>>>
>>>>>
>>>>> org.apache.struts.chain.commands.ActionCommandBase.execute(ActionCommandBase.java:51)
>>>>>       at
>>>>> org.apache.commons.chain.impl.ChainBase.execute(ChainBase.java:190)
>>>>>       at
>>>>>
>>>>>
>>>>> org.apache.commons.chain.generic.LookupCommand.execute(LookupCommand.java:304)
>>>>>       at
>>>>> org.apache.commons.chain.impl.ChainBase.execute(ChainBase.java:190)
>>>>>       at
>>>>>
>>>>>
>>>>> org.apache.struts.chain.ComposableRequestProcessor.process(ComposableRequestProcessor.java:283)
>>>>>       at
>>>>> org.apache.struts.action.ActionServlet.process(ActionServlet.java:1913)
>>>>>       at
>>>>> org.apache.struts.action.ActionServlet.doPost(ActionServlet.java:462)
>>>>>       at javax.servlet.http.HttpServlet.service(HttpServlet.java:710)
>>>>>       at javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
>>>>>       at
>>>>>
>>>>>
>>>>> org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:269)
>>>>>       at
>>>>>
>>>>>
>>>>> org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:188)
>>>>>       at
>>>>>
>>>>>
>>>>> org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:210)
>>>>>       at
>>>>>
>>>>>
>>>>> org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:174)
>>>>>       at
>>>>>
>>>>>
>>>>> org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)
>>>>>       at
>>>>>
>>>>>
>>>>> org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:117)
>>>>>       at
>>>>>
>>>>>
>>>>> org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:108)
>>>>>       at
>>>>>
>>>>>
>>>>> org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:151)
>>>>>       at
>>>>>
>>>>> org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:870)
>>>>>       at
>>>>>
>>>>>
>>>>> org.apache.coyote.http11.Http11BaseProtocol$Http11ConnectionHandler.processConnection(Http11BaseProtocol.java:665)
>>>>>       at
>>>>>
>>>>>
>>>>> org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpoint.java:528)
>>>>>       at
>>>>>
>>>>>
>>>>> org.apache.tomcat.util.net.LeaderFollowerWorkerThread.runIt(LeaderFollowerWorkerThread.java:81)
>>>>>       at
>>>>>
>>>>>
>>>>> org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:685)
>>>>>       at java.lang.Thread.run(Unknown Source)
>>>>> "/tmp/crmsauth.log.20081001" 561 lines, 48080 characters
>>>>>       at
>>>>>
>>>>>
>>>>> org.apache.coyote.http11.Http11BaseProtocol$Http11ConnectionHandler.processConnection(Http11BaseProtocol.java:665)
>>>>>       at
>>>>>
>>>>>
>>>>> org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpoint.java:528)
>>>>>       at
>>>>>
>>>>>
>>>>> org.apache.tomcat.util.net.LeaderFollowerWorkerThread.runIt(LeaderFollowerWorkerThread.java:81)
>>>>>       at
>>>>>
>>>>>
>>>>> org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:685)
>>>>>       at java.lang.Thread.run(Unknown Source)
>>>>> [/code]
>>>>>
>>>>> What i dont understand is why it works on the installation on the
>>>>> windows
>>>>> environment but not in the Unix environment. I check all the libraries
>>>>> and
>>>>> everything under common/lib is the same for both environments.
>>>>>
>>>>> Thanks
>>>>>
>>>>> Edited by: ziggy on Oct 1, 2008 3:48 PM
>>>>>
>>>>> Edited by: ziggy on Oct 1, 2008 3:50 PM
>>>>>
>>>>>
>>>>>
>>>>>
>>>>>
>>>> ---------------------------------------------------------------------
>>>> To start a new topic, e-mail: users@tomcat.apache.org
>>>> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
>>>> For additional commands, e-mail: users-help@tomcat.apache.org
>>>>
>>>>
>>>>
>>>>
>>>
>>>
>>>
>>
>>
>> ---------------------------------------------------------------------
>> To start a new topic, e-mail: users@tomcat.apache.org
>> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
>> For additional commands, e-mail: users-help@tomcat.apache.org
>>
>>
>

Re: javax.naming.NamingException: Cannot create resource instance

Posted by Ziggy O <di...@gmail.com>.
Hi,

The tomcat version on my Desktop is 5.5.27 and the Tomcat version on the
Unix environment is 5.5.23. Could the above minor version difference cause
it?

One thing i have noticed is that if i take the /META-INF/Context.xml file
and copy it into $CATALINA_HOME/conf/Catalina/localhost/testapp.xml it does
work.

i.e. why does it require the context file in that directory and why does it
have to be renamed to my applications context. On the Windows environment i
dont have to rename and copy the context file to
$CATALINA_HOME/conf/Catalina/localhost

Thanks



On Thu, Oct 2, 2008 at 12:55 PM, David Smith <dn...@cornell.edu> wrote:

> Ok...
>
> 1) I don't see a tomcat version, could you post that?
> 2) Are you sure the tomcat version on the production environment the same
> as your dev system?
> 3) This is probably not causing the immediate problem, but <res-type> ...
> </res-type> in your web.xml should be javax.sql.Datasource, not
> oracle.jdbc.pool.OracleDataSource.
>
> --David
>
>
> Ziggy O wrote:
>
>> No mate that was the full stack trace.
>>
>> Thanks
>>
>>
>> On Wed, Oct 1, 2008 at 7:02 PM, David Smith <dn...@cornell.edu> wrote:
>>
>>
>>
>>> Seems like such a generic error would have a root cause.  Was there
>>> anything more to the stack trace?
>>>
>>> --David
>>>
>>>
>>> Ziggy O wrote:
>>>
>>>
>>>
>>>> Hi,
>>>>
>>>> I am trying to connect to an oracle database but cant seem to get the
>>>> jdbc
>>>> connection to work. I am developing the application on a Windows desktop
>>>> and
>>>> transferring it onto a Unix box.
>>>>
>>>> When i test it on the Windows environmnet it does manage to connect but
>>>> if
>>>> i
>>>> test it on unix then i get an error. My gut feeling is that the
>>>> installation
>>>> on the unix environment is missing a library but i cant figure out what
>>>> it
>>>> is.
>>>>
>>>> Here is how i am trying to get the jndi connection.
>>>>
>>>> [code]
>>>> String fullname;
>>>>       if (jndiPrefix != null && jndiPrefix.length() > 0)
>>>>           fullname = jndiPrefix + datasource;
>>>>       else
>>>>           fullname = datasource;
>>>>
>>>>       // JNDI
>>>>       Context ctx = null;
>>>>       DataSource ds = null;
>>>>       Connection conn = null;
>>>>
>>>>       try
>>>>       {
>>>>           ctx = new InitialContext();
>>>>           Context envContext  = (Context)ctx.lookup("java:/comp/env");
>>>>           if (ctx != null)
>>>>           {
>>>>               ds = (DataSource)envContext.lookup(fullname);
>>>>               if (ds != null)
>>>>               {
>>>>                   conn = ds.getConnection();
>>>>               }
>>>>           }
>>>>       }
>>>> [/code]
>>>>
>>>> And here is the Configuration.
>>>>
>>>> Context.xml (User and password modified)
>>>>
>>>> [code]
>>>>  <Resource name="jdbc/theDb" auth="Container"
>>>>                     type="javax.sql.DataSource"
>>>> driverClassName="oracle.jdbc.driver.OracleDriver"
>>>>                     url="jdbc:oracle:thin:@localhost:1521:webdev"
>>>>                     username="webuser" password="webuser" maxActive="20"
>>>> maxIdle="10"
>>>>                     maxWait="-1"/>
>>>> [/code]
>>>>
>>>> web.xml
>>>>
>>>> [code]
>>>>   <resource-ref>
>>>>    <description>Oracle Datasource</description>
>>>>    <res-ref-name>jdbc/theDb</res-ref-name>
>>>>    <res-type>oracle.jdbc.pool.OracleDataSource</res-type>
>>>>    <res-auth>Container</res-auth>
>>>>   </resource-ref>
>>>>
>>>> [/code]
>>>>
>>>> And here is the stack trace of the error
>>>>
>>>> [code]
>>>> javax.naming.NamingException: Cannot create resource instance
>>>>       at
>>>>
>>>>
>>>> org.apache.naming.factory.ResourceFactory.getObjectInstance(ResourceFactory.java:143)
>>>>       at javax.naming.spi.NamingManager.getObjectInstance(Unknown
>>>> Source)
>>>>       at org.apache.naming.NamingContext.lookup(NamingContext.java:793)
>>>>       at org.apache.naming.NamingContext.lookup(NamingContext.java:140)
>>>>       at org.apache.naming.NamingContext.lookup(NamingContext.java:781)
>>>>       at org.apache.naming.NamingContext.lookup(NamingContext.java:153)
>>>>       at
>>>> com.bt.ccs21.util.DbConnection.getJNDIConnection(DbConnection.java:334)
>>>>       at
>>>> com.bt.ccs21.util.DbConnection.getJNDIConnection(DbConnection.java:256)
>>>>       at
>>>> com.bt.ccs21.util.DbConnection.getJRunConnection(DbConnection.java:286)
>>>>       at
>>>>
>>>>
>>>> com.bt.ccs21.presentation.events.admin.LogonActionPost.preAction(LogonActionPost.java:118)
>>>>       at
>>>>
>>>>
>>>> com.bt.ccs21.presentation.events.CCS21EventAction.execute(CCS21EventAction.java:29)
>>>>       at
>>>>
>>>>
>>>> org.apache.struts.chain.commands.servlet.ExecuteAction.execute(ExecuteAction.java:58)
>>>>       at
>>>>
>>>>
>>>> org.apache.struts.chain.commands.AbstractExecuteAction.execute(AbstractExecuteAction.java:67)
>>>>       at
>>>>
>>>>
>>>> org.apache.struts.chain.commands.ActionCommandBase.execute(ActionCommandBase.java:51)
>>>>       at
>>>> org.apache.commons.chain.impl.ChainBase.execute(ChainBase.java:190)
>>>>       at
>>>>
>>>>
>>>> org.apache.commons.chain.generic.LookupCommand.execute(LookupCommand.java:304)
>>>>       at
>>>> org.apache.commons.chain.impl.ChainBase.execute(ChainBase.java:190)
>>>>       at
>>>>
>>>>
>>>> org.apache.struts.chain.ComposableRequestProcessor.process(ComposableRequestProcessor.java:283)
>>>>       at
>>>> org.apache.struts.action.ActionServlet.process(ActionServlet.java:1913)
>>>>       at
>>>> org.apache.struts.action.ActionServlet.doPost(ActionServlet.java:462)
>>>>       at javax.servlet.http.HttpServlet.service(HttpServlet.java:710)
>>>>       at javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
>>>>       at
>>>>
>>>>
>>>> org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:269)
>>>>       at
>>>>
>>>>
>>>> org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:188)
>>>>       at
>>>>
>>>>
>>>> org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:210)
>>>>       at
>>>>
>>>>
>>>> org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:174)
>>>>       at
>>>>
>>>>
>>>> org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)
>>>>       at
>>>>
>>>>
>>>> org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:117)
>>>>       at
>>>>
>>>>
>>>> org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:108)
>>>>       at
>>>>
>>>>
>>>> org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:151)
>>>>       at
>>>>
>>>> org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:870)
>>>>       at
>>>>
>>>>
>>>> org.apache.coyote.http11.Http11BaseProtocol$Http11ConnectionHandler.processConnection(Http11BaseProtocol.java:665)
>>>>       at
>>>>
>>>>
>>>> org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpoint.java:528)
>>>>       at
>>>>
>>>>
>>>> org.apache.tomcat.util.net.LeaderFollowerWorkerThread.runIt(LeaderFollowerWorkerThread.java:81)
>>>>       at
>>>>
>>>>
>>>> org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:685)
>>>>       at java.lang.Thread.run(Unknown Source)
>>>> "/tmp/crmsauth.log.20081001" 561 lines, 48080 characters
>>>>       at
>>>>
>>>>
>>>> org.apache.coyote.http11.Http11BaseProtocol$Http11ConnectionHandler.processConnection(Http11BaseProtocol.java:665)
>>>>       at
>>>>
>>>>
>>>> org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpoint.java:528)
>>>>       at
>>>>
>>>>
>>>> org.apache.tomcat.util.net.LeaderFollowerWorkerThread.runIt(LeaderFollowerWorkerThread.java:81)
>>>>       at
>>>>
>>>>
>>>> org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:685)
>>>>       at java.lang.Thread.run(Unknown Source)
>>>> [/code]
>>>>
>>>> What i dont understand is why it works on the installation on the
>>>> windows
>>>> environment but not in the Unix environment. I check all the libraries
>>>> and
>>>> everything under common/lib is the same for both environments.
>>>>
>>>> Thanks
>>>>
>>>> Edited by: ziggy on Oct 1, 2008 3:48 PM
>>>>
>>>> Edited by: ziggy on Oct 1, 2008 3:50 PM
>>>>
>>>>
>>>>
>>>>
>>>>
>>> ---------------------------------------------------------------------
>>> To start a new topic, e-mail: users@tomcat.apache.org
>>> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
>>> For additional commands, e-mail: users-help@tomcat.apache.org
>>>
>>>
>>>
>>>
>>
>>
>>
>
>
> ---------------------------------------------------------------------
> To start a new topic, e-mail: users@tomcat.apache.org
> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
> For additional commands, e-mail: users-help@tomcat.apache.org
>
>

Re: javax.naming.NamingException: Cannot create resource instance

Posted by David Smith <dn...@cornell.edu>.
Ok...

1) I don't see a tomcat version, could you post that?
2) Are you sure the tomcat version on the production environment the 
same as your dev system?
3) This is probably not causing the immediate problem, but <res-type> 
... </res-type> in your web.xml should be javax.sql.Datasource, not 
oracle.jdbc.pool.OracleDataSource.

--David

Ziggy O wrote:
> No mate that was the full stack trace.
>
> Thanks
>
>
> On Wed, Oct 1, 2008 at 7:02 PM, David Smith <dn...@cornell.edu> wrote:
>
>   
>> Seems like such a generic error would have a root cause.  Was there
>> anything more to the stack trace?
>>
>> --David
>>
>>
>> Ziggy O wrote:
>>
>>     
>>> Hi,
>>>
>>> I am trying to connect to an oracle database but cant seem to get the jdbc
>>> connection to work. I am developing the application on a Windows desktop
>>> and
>>> transferring it onto a Unix box.
>>>
>>> When i test it on the Windows environmnet it does manage to connect but if
>>> i
>>> test it on unix then i get an error. My gut feeling is that the
>>> installation
>>> on the unix environment is missing a library but i cant figure out what it
>>> is.
>>>
>>> Here is how i am trying to get the jndi connection.
>>>
>>> [code]
>>> String fullname;
>>>        if (jndiPrefix != null && jndiPrefix.length() > 0)
>>>            fullname = jndiPrefix + datasource;
>>>        else
>>>            fullname = datasource;
>>>
>>>        // JNDI
>>>        Context ctx = null;
>>>        DataSource ds = null;
>>>        Connection conn = null;
>>>
>>>        try
>>>        {
>>>            ctx = new InitialContext();
>>>            Context envContext  = (Context)ctx.lookup("java:/comp/env");
>>>            if (ctx != null)
>>>            {
>>>                ds = (DataSource)envContext.lookup(fullname);
>>>                if (ds != null)
>>>                {
>>>                    conn = ds.getConnection();
>>>                }
>>>            }
>>>        }
>>> [/code]
>>>
>>> And here is the Configuration.
>>>
>>> Context.xml (User and password modified)
>>>
>>> [code]
>>>  <Resource name="jdbc/theDb" auth="Container"
>>>                      type="javax.sql.DataSource"
>>> driverClassName="oracle.jdbc.driver.OracleDriver"
>>>                      url="jdbc:oracle:thin:@localhost:1521:webdev"
>>>                      username="webuser" password="webuser" maxActive="20"
>>> maxIdle="10"
>>>                      maxWait="-1"/>
>>> [/code]
>>>
>>> web.xml
>>>
>>> [code]
>>>    <resource-ref>
>>>     <description>Oracle Datasource</description>
>>>     <res-ref-name>jdbc/theDb</res-ref-name>
>>>     <res-type>oracle.jdbc.pool.OracleDataSource</res-type>
>>>     <res-auth>Container</res-auth>
>>>    </resource-ref>
>>>
>>> [/code]
>>>
>>> And here is the stack trace of the error
>>>
>>> [code]
>>> javax.naming.NamingException: Cannot create resource instance
>>>        at
>>>
>>> org.apache.naming.factory.ResourceFactory.getObjectInstance(ResourceFactory.java:143)
>>>        at javax.naming.spi.NamingManager.getObjectInstance(Unknown Source)
>>>        at org.apache.naming.NamingContext.lookup(NamingContext.java:793)
>>>        at org.apache.naming.NamingContext.lookup(NamingContext.java:140)
>>>        at org.apache.naming.NamingContext.lookup(NamingContext.java:781)
>>>        at org.apache.naming.NamingContext.lookup(NamingContext.java:153)
>>>        at
>>> com.bt.ccs21.util.DbConnection.getJNDIConnection(DbConnection.java:334)
>>>        at
>>> com.bt.ccs21.util.DbConnection.getJNDIConnection(DbConnection.java:256)
>>>        at
>>> com.bt.ccs21.util.DbConnection.getJRunConnection(DbConnection.java:286)
>>>        at
>>>
>>> com.bt.ccs21.presentation.events.admin.LogonActionPost.preAction(LogonActionPost.java:118)
>>>        at
>>>
>>> com.bt.ccs21.presentation.events.CCS21EventAction.execute(CCS21EventAction.java:29)
>>>        at
>>>
>>> org.apache.struts.chain.commands.servlet.ExecuteAction.execute(ExecuteAction.java:58)
>>>        at
>>>
>>> org.apache.struts.chain.commands.AbstractExecuteAction.execute(AbstractExecuteAction.java:67)
>>>        at
>>>
>>> org.apache.struts.chain.commands.ActionCommandBase.execute(ActionCommandBase.java:51)
>>>        at
>>> org.apache.commons.chain.impl.ChainBase.execute(ChainBase.java:190)
>>>        at
>>>
>>> org.apache.commons.chain.generic.LookupCommand.execute(LookupCommand.java:304)
>>>        at
>>> org.apache.commons.chain.impl.ChainBase.execute(ChainBase.java:190)
>>>        at
>>>
>>> org.apache.struts.chain.ComposableRequestProcessor.process(ComposableRequestProcessor.java:283)
>>>        at
>>> org.apache.struts.action.ActionServlet.process(ActionServlet.java:1913)
>>>        at
>>> org.apache.struts.action.ActionServlet.doPost(ActionServlet.java:462)
>>>        at javax.servlet.http.HttpServlet.service(HttpServlet.java:710)
>>>        at javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
>>>        at
>>>
>>> org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:269)
>>>        at
>>>
>>> org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:188)
>>>        at
>>>
>>> org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:210)
>>>        at
>>>
>>> org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:174)
>>>        at
>>>
>>> org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)
>>>        at
>>>
>>> org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:117)
>>>        at
>>>
>>> org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:108)
>>>        at
>>>
>>> org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:151)
>>>        at
>>> org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:870)
>>>        at
>>>
>>> org.apache.coyote.http11.Http11BaseProtocol$Http11ConnectionHandler.processConnection(Http11BaseProtocol.java:665)
>>>        at
>>>
>>> org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpoint.java:528)
>>>        at
>>>
>>> org.apache.tomcat.util.net.LeaderFollowerWorkerThread.runIt(LeaderFollowerWorkerThread.java:81)
>>>        at
>>>
>>> org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:685)
>>>        at java.lang.Thread.run(Unknown Source)
>>> "/tmp/crmsauth.log.20081001" 561 lines, 48080 characters
>>>        at
>>>
>>> org.apache.coyote.http11.Http11BaseProtocol$Http11ConnectionHandler.processConnection(Http11BaseProtocol.java:665)
>>>        at
>>>
>>> org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpoint.java:528)
>>>        at
>>>
>>> org.apache.tomcat.util.net.LeaderFollowerWorkerThread.runIt(LeaderFollowerWorkerThread.java:81)
>>>        at
>>>
>>> org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:685)
>>>        at java.lang.Thread.run(Unknown Source)
>>> [/code]
>>>
>>> What i dont understand is why it works on the installation on the windows
>>> environment but not in the Unix environment. I check all the libraries and
>>> everything under common/lib is the same for both environments.
>>>
>>> Thanks
>>>
>>> Edited by: ziggy on Oct 1, 2008 3:48 PM
>>>
>>> Edited by: ziggy on Oct 1, 2008 3:50 PM
>>>
>>>
>>>
>>>       
>> ---------------------------------------------------------------------
>> To start a new topic, e-mail: users@tomcat.apache.org
>> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
>> For additional commands, e-mail: users-help@tomcat.apache.org
>>
>>
>>     
>
>   


---------------------------------------------------------------------
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Re: javax.naming.NamingException: Cannot create resource instance

Posted by Ziggy O <di...@gmail.com>.
No mate that was the full stack trace.

Thanks


On Wed, Oct 1, 2008 at 7:02 PM, David Smith <dn...@cornell.edu> wrote:

> Seems like such a generic error would have a root cause.  Was there
> anything more to the stack trace?
>
> --David
>
>
> Ziggy O wrote:
>
>> Hi,
>>
>> I am trying to connect to an oracle database but cant seem to get the jdbc
>> connection to work. I am developing the application on a Windows desktop
>> and
>> transferring it onto a Unix box.
>>
>> When i test it on the Windows environmnet it does manage to connect but if
>> i
>> test it on unix then i get an error. My gut feeling is that the
>> installation
>> on the unix environment is missing a library but i cant figure out what it
>> is.
>>
>> Here is how i am trying to get the jndi connection.
>>
>> [code]
>> String fullname;
>>        if (jndiPrefix != null && jndiPrefix.length() > 0)
>>            fullname = jndiPrefix + datasource;
>>        else
>>            fullname = datasource;
>>
>>        // JNDI
>>        Context ctx = null;
>>        DataSource ds = null;
>>        Connection conn = null;
>>
>>        try
>>        {
>>            ctx = new InitialContext();
>>            Context envContext  = (Context)ctx.lookup("java:/comp/env");
>>            if (ctx != null)
>>            {
>>                ds = (DataSource)envContext.lookup(fullname);
>>                if (ds != null)
>>                {
>>                    conn = ds.getConnection();
>>                }
>>            }
>>        }
>> [/code]
>>
>> And here is the Configuration.
>>
>> Context.xml (User and password modified)
>>
>> [code]
>>  <Resource name="jdbc/theDb" auth="Container"
>>                      type="javax.sql.DataSource"
>> driverClassName="oracle.jdbc.driver.OracleDriver"
>>                      url="jdbc:oracle:thin:@localhost:1521:webdev"
>>                      username="webuser" password="webuser" maxActive="20"
>> maxIdle="10"
>>                      maxWait="-1"/>
>> [/code]
>>
>> web.xml
>>
>> [code]
>>    <resource-ref>
>>     <description>Oracle Datasource</description>
>>     <res-ref-name>jdbc/theDb</res-ref-name>
>>     <res-type>oracle.jdbc.pool.OracleDataSource</res-type>
>>     <res-auth>Container</res-auth>
>>    </resource-ref>
>>
>> [/code]
>>
>> And here is the stack trace of the error
>>
>> [code]
>> javax.naming.NamingException: Cannot create resource instance
>>        at
>>
>> org.apache.naming.factory.ResourceFactory.getObjectInstance(ResourceFactory.java:143)
>>        at javax.naming.spi.NamingManager.getObjectInstance(Unknown Source)
>>        at org.apache.naming.NamingContext.lookup(NamingContext.java:793)
>>        at org.apache.naming.NamingContext.lookup(NamingContext.java:140)
>>        at org.apache.naming.NamingContext.lookup(NamingContext.java:781)
>>        at org.apache.naming.NamingContext.lookup(NamingContext.java:153)
>>        at
>> com.bt.ccs21.util.DbConnection.getJNDIConnection(DbConnection.java:334)
>>        at
>> com.bt.ccs21.util.DbConnection.getJNDIConnection(DbConnection.java:256)
>>        at
>> com.bt.ccs21.util.DbConnection.getJRunConnection(DbConnection.java:286)
>>        at
>>
>> com.bt.ccs21.presentation.events.admin.LogonActionPost.preAction(LogonActionPost.java:118)
>>        at
>>
>> com.bt.ccs21.presentation.events.CCS21EventAction.execute(CCS21EventAction.java:29)
>>        at
>>
>> org.apache.struts.chain.commands.servlet.ExecuteAction.execute(ExecuteAction.java:58)
>>        at
>>
>> org.apache.struts.chain.commands.AbstractExecuteAction.execute(AbstractExecuteAction.java:67)
>>        at
>>
>> org.apache.struts.chain.commands.ActionCommandBase.execute(ActionCommandBase.java:51)
>>        at
>> org.apache.commons.chain.impl.ChainBase.execute(ChainBase.java:190)
>>        at
>>
>> org.apache.commons.chain.generic.LookupCommand.execute(LookupCommand.java:304)
>>        at
>> org.apache.commons.chain.impl.ChainBase.execute(ChainBase.java:190)
>>        at
>>
>> org.apache.struts.chain.ComposableRequestProcessor.process(ComposableRequestProcessor.java:283)
>>        at
>> org.apache.struts.action.ActionServlet.process(ActionServlet.java:1913)
>>        at
>> org.apache.struts.action.ActionServlet.doPost(ActionServlet.java:462)
>>        at javax.servlet.http.HttpServlet.service(HttpServlet.java:710)
>>        at javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
>>        at
>>
>> org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:269)
>>        at
>>
>> org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:188)
>>        at
>>
>> org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:210)
>>        at
>>
>> org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:174)
>>        at
>>
>> org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)
>>        at
>>
>> org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:117)
>>        at
>>
>> org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:108)
>>        at
>>
>> org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:151)
>>        at
>> org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:870)
>>        at
>>
>> org.apache.coyote.http11.Http11BaseProtocol$Http11ConnectionHandler.processConnection(Http11BaseProtocol.java:665)
>>        at
>>
>> org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpoint.java:528)
>>        at
>>
>> org.apache.tomcat.util.net.LeaderFollowerWorkerThread.runIt(LeaderFollowerWorkerThread.java:81)
>>        at
>>
>> org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:685)
>>        at java.lang.Thread.run(Unknown Source)
>> "/tmp/crmsauth.log.20081001" 561 lines, 48080 characters
>>        at
>>
>> org.apache.coyote.http11.Http11BaseProtocol$Http11ConnectionHandler.processConnection(Http11BaseProtocol.java:665)
>>        at
>>
>> org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpoint.java:528)
>>        at
>>
>> org.apache.tomcat.util.net.LeaderFollowerWorkerThread.runIt(LeaderFollowerWorkerThread.java:81)
>>        at
>>
>> org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:685)
>>        at java.lang.Thread.run(Unknown Source)
>> [/code]
>>
>> What i dont understand is why it works on the installation on the windows
>> environment but not in the Unix environment. I check all the libraries and
>> everything under common/lib is the same for both environments.
>>
>> Thanks
>>
>> Edited by: ziggy on Oct 1, 2008 3:48 PM
>>
>> Edited by: ziggy on Oct 1, 2008 3:50 PM
>>
>>
>>
>
>
> ---------------------------------------------------------------------
> To start a new topic, e-mail: users@tomcat.apache.org
> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
> For additional commands, e-mail: users-help@tomcat.apache.org
>
>

Re: javax.naming.NamingException: Cannot create resource instance

Posted by David Smith <dn...@cornell.edu>.
Seems like such a generic error would have a root cause.  Was there 
anything more to the stack trace?

--David

Ziggy O wrote:
> Hi,
>
> I am trying to connect to an oracle database but cant seem to get the jdbc
> connection to work. I am developing the application on a Windows desktop and
> transferring it onto a Unix box.
>
> When i test it on the Windows environmnet it does manage to connect but if i
> test it on unix then i get an error. My gut feeling is that the installation
> on the unix environment is missing a library but i cant figure out what it
> is.
>
> Here is how i am trying to get the jndi connection.
>
> [code]
> String fullname;
>         if (jndiPrefix != null && jndiPrefix.length() > 0)
>             fullname = jndiPrefix + datasource;
>         else
>             fullname = datasource;
>
>         // JNDI
>         Context ctx = null;
>         DataSource ds = null;
>         Connection conn = null;
>
>         try
>         {
>             ctx = new InitialContext();
>             Context envContext  = (Context)ctx.lookup("java:/comp/env");
>             if (ctx != null)
>             {
>                 ds = (DataSource)envContext.lookup(fullname);
>                 if (ds != null)
>                 {
>                     conn = ds.getConnection();
>                 }
>             }
>         }
> [/code]
>
> And here is the Configuration.
>
> Context.xml (User and password modified)
>
> [code]
>   <Resource name="jdbc/theDb" auth="Container"
>                       type="javax.sql.DataSource"
> driverClassName="oracle.jdbc.driver.OracleDriver"
>                       url="jdbc:oracle:thin:@localhost:1521:webdev"
>                       username="webuser" password="webuser" maxActive="20"
> maxIdle="10"
>                       maxWait="-1"/>
> [/code]
>
> web.xml
>
> [code]
>     <resource-ref>
>      <description>Oracle Datasource</description>
>      <res-ref-name>jdbc/theDb</res-ref-name>
>      <res-type>oracle.jdbc.pool.OracleDataSource</res-type>
>      <res-auth>Container</res-auth>
>     </resource-ref>
>
> [/code]
>
> And here is the stack trace of the error
>
> [code]
> javax.naming.NamingException: Cannot create resource instance
>         at
> org.apache.naming.factory.ResourceFactory.getObjectInstance(ResourceFactory.java:143)
>         at javax.naming.spi.NamingManager.getObjectInstance(Unknown Source)
>         at org.apache.naming.NamingContext.lookup(NamingContext.java:793)
>         at org.apache.naming.NamingContext.lookup(NamingContext.java:140)
>         at org.apache.naming.NamingContext.lookup(NamingContext.java:781)
>         at org.apache.naming.NamingContext.lookup(NamingContext.java:153)
>         at
> com.bt.ccs21.util.DbConnection.getJNDIConnection(DbConnection.java:334)
>         at
> com.bt.ccs21.util.DbConnection.getJNDIConnection(DbConnection.java:256)
>         at
> com.bt.ccs21.util.DbConnection.getJRunConnection(DbConnection.java:286)
>         at
> com.bt.ccs21.presentation.events.admin.LogonActionPost.preAction(LogonActionPost.java:118)
>         at
> com.bt.ccs21.presentation.events.CCS21EventAction.execute(CCS21EventAction.java:29)
>         at
> org.apache.struts.chain.commands.servlet.ExecuteAction.execute(ExecuteAction.java:58)
>         at
> org.apache.struts.chain.commands.AbstractExecuteAction.execute(AbstractExecuteAction.java:67)
>         at
> org.apache.struts.chain.commands.ActionCommandBase.execute(ActionCommandBase.java:51)
>         at
> org.apache.commons.chain.impl.ChainBase.execute(ChainBase.java:190)
>         at
> org.apache.commons.chain.generic.LookupCommand.execute(LookupCommand.java:304)
>         at
> org.apache.commons.chain.impl.ChainBase.execute(ChainBase.java:190)
>         at
> org.apache.struts.chain.ComposableRequestProcessor.process(ComposableRequestProcessor.java:283)
>         at
> org.apache.struts.action.ActionServlet.process(ActionServlet.java:1913)
>         at
> org.apache.struts.action.ActionServlet.doPost(ActionServlet.java:462)
>         at javax.servlet.http.HttpServlet.service(HttpServlet.java:710)
>         at javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
>         at
> org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:269)
>         at
> org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:188)
>         at
> org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:210)
>         at
> org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:174)
>         at
> org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)
>         at
> org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:117)
>         at
> org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:108)
>         at
> org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:151)
>         at
> org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:870)
>         at
> org.apache.coyote.http11.Http11BaseProtocol$Http11ConnectionHandler.processConnection(Http11BaseProtocol.java:665)
>         at
> org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpoint.java:528)
>         at
> org.apache.tomcat.util.net.LeaderFollowerWorkerThread.runIt(LeaderFollowerWorkerThread.java:81)
>         at
> org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:685)
>         at java.lang.Thread.run(Unknown Source)
> "/tmp/crmsauth.log.20081001" 561 lines, 48080 characters
>         at
> org.apache.coyote.http11.Http11BaseProtocol$Http11ConnectionHandler.processConnection(Http11BaseProtocol.java:665)
>         at
> org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpoint.java:528)
>         at
> org.apache.tomcat.util.net.LeaderFollowerWorkerThread.runIt(LeaderFollowerWorkerThread.java:81)
>         at
> org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:685)
>         at java.lang.Thread.run(Unknown Source)
> [/code]
>
> What i dont understand is why it works on the installation on the windows
> environment but not in the Unix environment. I check all the libraries and
> everything under common/lib is the same for both environments.
>
> Thanks
>
> Edited by: ziggy on Oct 1, 2008 3:48 PM
>
> Edited by: ziggy on Oct 1, 2008 3:50 PM
>
>   


---------------------------------------------------------------------
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org