You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by Amol Chaudhari <av...@gmail.com> on 2007/07/26 17:32:43 UTC

Cannot create resource instance

Hello Everyone,
I am trying to migrate a sun java studio creator JSF (which uses Sun App
Server 8) project to Netbeans 5.5 + inbuilt Tomcat 5.5.17. While trying to
add a new record to my screen i am getting the following exception. Can
anyone help me on this?

javax.naming.NamingException: Cannot create resource instance
	at
org.apache.naming.factory.TransactionFactory.getObjectInstance(TransactionFactory.java:112)
	at javax.naming.spi.NamingManager.getObjectInstance(NamingManager.java:304)
	at org.apache.naming.NamingContext.lookup(NamingContext.java:792)
	at org.apache.naming.NamingContext.lookup(NamingContext.java:139)
	at org.apache.naming.NamingContext.lookup(NamingContext.java:780)
	at org.apache.naming.NamingContext.lookup(NamingContext.java:152)
	at org.apache.naming.SelectorContext.lookup(SelectorContext.java:136)
	at javax.naming.InitialContext.lookup(InitialContext.java:351)
	at test.Student.btnSave_action(Student.java:593)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
	at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
	at java.lang.reflect.Method.invoke(Method.java:585)
	at com.sun.faces.el.MethodBindingImpl.invoke(MethodBindingImpl.java:126)
	at
com.sun.faces.application.ActionListenerImpl.processAction(ActionListenerImpl.java:72)
	at
com.sun.rave.web.ui.appbase.faces.ActionListenerImpl.processAction(ActionListenerImpl.java:57)
	at
org.ajax4jsf.framework.ajax.AjaxActionComponent.broadcast(AjaxActionComponent.java:88)
	at
org.ajax4jsf.framework.ajax.AjaxViewRoot.processEvents(AjaxViewRoot.java:287)
	at
org.ajax4jsf.framework.ajax.AjaxViewRoot.broadcastEvents(AjaxViewRoot.java:263)
	at
org.ajax4jsf.framework.ajax.AjaxViewRoot.processApplication(AjaxViewRoot.java:410)
	at
com.sun.faces.lifecycle.InvokeApplicationPhase.execute(InvokeApplicationPhase.java:75)
	at com.sun.faces.lifecycle.LifecycleImpl.phase(LifecycleImpl.java:221)
	at com.sun.faces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:90)
	at javax.faces.webapp.FacesServlet.service(FacesServlet.java:197)
	at
org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:252)
	at
org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
	at com.sun.rave.web.ui.util.UploadFilter.doFilter(UploadFilter.java:194)
	at
org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:202)
	at
org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
	at
org.ajax4jsf.framework.ajax.xmlfilter.BaseFilter.doXmlFilter(BaseFilter.java:574)
	at
org.ajax4jsf.framework.ajax.xmlfilter.BaseFilter.doFilter(BaseFilter.java:387)
	at
org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:202)
	at
org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
	at
org.apache.myfaces.webapp.filter.ExtensionsFilter.doFilter(ExtensionsFilter.java:144)
	at
org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:202)
	at
org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
	at
org.netbeans.modules.web.monitor.server.MonitorFilter.doFilter(MonitorFilter.java:368)
	at
org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:202)
	at
org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
	at
org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:213)
	at
org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:178)
	at
org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:524)
	at
org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:126)
	at
org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:105)
	at
org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:107)
	at
org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:148)
	at
org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:869)
	at
org.apache.coyote.http11.Http11BaseProtocol$Http11ConnectionHandler.processConnection(Http11BaseProtocol.java:664)
	at
org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpoint.java:527)
	at
org.apache.tomcat.util.net.LeaderFollowerWorkerThread.runIt(LeaderFollowerWorkerThread.java:80)
	at
org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:684)
	at java.lang.Thread.run(Thread.java:595)


-- 
View this message in context: http://www.nabble.com/Cannot-create-resource-instance-tf4152380.html#a11812926
Sent from the Tomcat - User mailing list archive at Nabble.com.


---------------------------------------------------------------------
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: Cannot create resource instance

Posted by Christopher Schultz <ch...@christopherschultz.net>.
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Amol,

Amol Chaudhari wrote:
> jndiContextRoot.lookup("java:comp/UserTransaction");

Did you ever setup this JNDI object? Where is the configuration for
that? (Please excuse my ignorance... I don't use transations in such a
manner).

> If I comment out the UserTransaction part from the above code, things
> work perfectly fine.

Really? I would have expected NullPointerExceptions all over the place
if you never retrieved the UserTransaction object successfully.

> Here you may say that its not necessary to use it. But this is my
> sample application, built simply to localize the problem. In my
> project it is necessary to use it.

Okay. How does the transaction thing get into JNDI? Do you create that
object somewhere and stuff it in there? It seems a little fragile...
don't multiple requests to the same page share that transaction and ...
well, totally fail? Again, I may completely misunderstand the way these
JNDI-based transactions work.

- -chris
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.7 (MingW32)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iD8DBQFGrfGT9CaO5/Lv0PARAvZsAKCEG72zPQBcuEG+ctnX7zc+FVtegwCgihYG
Gxp3sRmWNcgK9IRHtYUlY0M=
=HU6N
-----END PGP SIGNATURE-----

---------------------------------------------------------------------
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: Cannot create resource instance

Posted by Amol Chaudhari <av...@gmail.com>.
Chris,
Thanks for the reply.
Here's my complete btnSave_action method :-
public String btnSave_action() {
        System.out.println("in btnSave_action...");
        UserTransaction userTransaction = null;
        try {
            Context jndiContextRoot = new InitialContext();
            userTransaction = (UserTransaction)
jndiContextRoot.lookup("java:comp/UserTransaction");
        } catch (NamingException ne) {
            System.out.println("Exception occurred while
UserTransaction Initial Context lookup");
            ne.printStackTrace();
        }
        Connection conn = createConnection();
        if(conn != null) {
            CallableStatement stmt = null;
            try {
            userTransaction.begin();

                System.out.println("Got the Connection...");

                stmt = getCallableStatement(conn);
                System.out.println("Got the callable statement");
                if(stmt != null) {
                    System.out.println("Statement not null...");
                    execute(stmt);
                    System.out.println("Executed Statement");
                }
            userTransaction.commit();
            } catch (Exception ex) {
                System.out.println("Exception Occurred.. ");
            try {
                userTransaction.rollback();
            } catch (SystemException se) {
                System.out.println("Exception occurred while rolling
back the transaction");
            }
            } finally {
                try {
                    stmt.close();
                } catch (SQLException ex) {
                    ex.printStackTrace();
                }
                closeConnection(conn);
            }
            System.out.println("Connection closed...");
        } else {
            System.out.println("The connection can not be created.");
        }
        return null;
    }

If I comment out the UserTransaction part from the above code, things
work perfectly fine.
Here you may say that its not necessary to use it. But this is my
sample application, built simply to localize the problem. In my
project it is necessary to use it.


Also following is my configuration for the JNDI datasource:

<Context path="/Student">
    <Resource auth="Container"
driverClassName="com.ibm.db2.jcc.DB2Driver" maxActive="20"
maxIdle="10" maxWait="-1" name="jdbc/ACM" password="db2inst"
type="javax.sql.DataSource"
url="jdbc:db2://192.168.11.103:50001/AMOL2" username="db2inst"/>
</Context>



On 7/28/07, Christopher Schultz <ch...@christopherschultz.net> wrote:
> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA1
>
> Amol,
>
> Amol Chaudhari wrote:
> > Can't any of the gurus help me on this?
>
> Perhaps. Can you post the code you are using near this line of code:
>
> test.Student.btnSave_action(Student.java:593)
>
> Also describe how you are configuring your JNDI DataSource. In fact,
> please include your DataSource configuration.
>
> This problem (misconfigured JNDI DataSource) happens to a lot of people,
> and it's usually something simple but takes a while to figure out.
>
> - -chris
>
> -----BEGIN PGP SIGNATURE-----
> Version: GnuPG v1.4.7 (MingW32)
> Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org
>
> iD8DBQFGqjqe9CaO5/Lv0PARAkkyAJ9k18Rgm6D/+DvbU1QcibETJoglKACeL1SL
> QgUI5aL4UkWB/iL66fmmljk=
> =TuUz
> -----END PGP SIGNATURE-----
>
> ---------------------------------------------------------------------
> 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: Cannot create resource instance

Posted by Christopher Schultz <ch...@christopherschultz.net>.
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Amol,

Amol Chaudhari wrote:
> Can't any of the gurus help me on this?

Perhaps. Can you post the code you are using near this line of code:

test.Student.btnSave_action(Student.java:593)

Also describe how you are configuring your JNDI DataSource. In fact,
please include your DataSource configuration.

This problem (misconfigured JNDI DataSource) happens to a lot of people,
and it's usually something simple but takes a while to figure out.

- -chris

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.7 (MingW32)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iD8DBQFGqjqe9CaO5/Lv0PARAkkyAJ9k18Rgm6D/+DvbU1QcibETJoglKACeL1SL
QgUI5aL4UkWB/iL66fmmljk=
=TuUz
-----END PGP SIGNATURE-----

---------------------------------------------------------------------
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: Cannot create resource instance

Posted by Amol Chaudhari <av...@gmail.com>.
Can't any of the gurus help me on this?
I tried to follow the steps given in one thread:
http://www.nabble.com/UserTransaction%2C-JOTM-and-Tomcat-5.5.x-tf1073172.html#a10830695
but now the problem has worsened. Now my Navigation is also not working
leave alone the adding of new record.
I am stuck on this and do not have much experience on deployment issues. I
will appreciate if anyone can help me out..



Amol Chaudhari wrote:
> 
> Hello Everyone,
> I am trying to migrate a sun java studio creator JSF (which uses Sun App
> Server 8) project to Netbeans 5.5 + inbuilt Tomcat 5.5.17. While trying to
> add a new record to my screen i am getting the following exception. Can
> anyone help me on this?
> 
> javax.naming.NamingException: Cannot create resource instance
> 	at
> org.apache.naming.factory.TransactionFactory.getObjectInstance(TransactionFactory.java:112)
> 	at
> javax.naming.spi.NamingManager.getObjectInstance(NamingManager.java:304)
> 	at org.apache.naming.NamingContext.lookup(NamingContext.java:792)
> 	at org.apache.naming.NamingContext.lookup(NamingContext.java:139)
> 	at org.apache.naming.NamingContext.lookup(NamingContext.java:780)
> 	at org.apache.naming.NamingContext.lookup(NamingContext.java:152)
> 	at org.apache.naming.SelectorContext.lookup(SelectorContext.java:136)
> 	at javax.naming.InitialContext.lookup(InitialContext.java:351)
> 	at test.Student.btnSave_action(Student.java:593)
> 	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
> 	at
> sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
> 	at
> sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
> 	at java.lang.reflect.Method.invoke(Method.java:585)
> 	at com.sun.faces.el.MethodBindingImpl.invoke(MethodBindingImpl.java:126)
> 	at
> com.sun.faces.application.ActionListenerImpl.processAction(ActionListenerImpl.java:72)
> 	at
> com.sun.rave.web.ui.appbase.faces.ActionListenerImpl.processAction(ActionListenerImpl.java:57)
> 	at
> org.ajax4jsf.framework.ajax.AjaxActionComponent.broadcast(AjaxActionComponent.java:88)
> 	at
> org.ajax4jsf.framework.ajax.AjaxViewRoot.processEvents(AjaxViewRoot.java:287)
> 	at
> org.ajax4jsf.framework.ajax.AjaxViewRoot.broadcastEvents(AjaxViewRoot.java:263)
> 	at
> org.ajax4jsf.framework.ajax.AjaxViewRoot.processApplication(AjaxViewRoot.java:410)
> 	at
> com.sun.faces.lifecycle.InvokeApplicationPhase.execute(InvokeApplicationPhase.java:75)
> 	at com.sun.faces.lifecycle.LifecycleImpl.phase(LifecycleImpl.java:221)
> 	at com.sun.faces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:90)
> 	at javax.faces.webapp.FacesServlet.service(FacesServlet.java:197)
> 	at
> org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:252)
> 	at
> org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
> 	at com.sun.rave.web.ui.util.UploadFilter.doFilter(UploadFilter.java:194)
> 	at
> org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:202)
> 	at
> org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
> 	at
> org.ajax4jsf.framework.ajax.xmlfilter.BaseFilter.doXmlFilter(BaseFilter.java:574)
> 	at
> org.ajax4jsf.framework.ajax.xmlfilter.BaseFilter.doFilter(BaseFilter.java:387)
> 	at
> org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:202)
> 	at
> org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
> 	at
> org.apache.myfaces.webapp.filter.ExtensionsFilter.doFilter(ExtensionsFilter.java:144)
> 	at
> org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:202)
> 	at
> org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
> 	at
> org.netbeans.modules.web.monitor.server.MonitorFilter.doFilter(MonitorFilter.java:368)
> 	at
> org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:202)
> 	at
> org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
> 	at
> org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:213)
> 	at
> org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:178)
> 	at
> org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:524)
> 	at
> org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:126)
> 	at
> org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:105)
> 	at
> org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:107)
> 	at
> org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:148)
> 	at
> org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:869)
> 	at
> org.apache.coyote.http11.Http11BaseProtocol$Http11ConnectionHandler.processConnection(Http11BaseProtocol.java:664)
> 	at
> org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpoint.java:527)
> 	at
> org.apache.tomcat.util.net.LeaderFollowerWorkerThread.runIt(LeaderFollowerWorkerThread.java:80)
> 	at
> org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:684)
> 	at java.lang.Thread.run(Thread.java:595)
> 
> 
> 

-- 
View this message in context: http://www.nabble.com/Cannot-create-resource-instance-tf4152380.html#a11830837
Sent from the Tomcat - User mailing list archive at Nabble.com.


---------------------------------------------------------------------
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