title: Problem to deploy war in glassfish
body: <p>when i want to deploy my web application ( i make it with netbeans) in glassfish i have this error</p>
  
  <blockquote>
    <p>Error occurred during deployment: Exception while preparing the app : Invalid resource : tun__pm. Please see server.log for more details</p>
  </blockquote>
  
  <p>The application is a RESTful web service , when i test it , netbeans deploy it and it work fine . But when i took the .war file and want to deploy it i have the error .</p>
  
  <p>this is the log:</p>
  
  <pre><code>&gt; [#|2011-04-30T19:50:05.229+0100|SEVERE|glassfish3.1|javax.enterprise.system.core.com.sun.enterprise.v3.server|_ThreadID=84;_ThreadName=Thread-3;|Invalid
  &gt; resource : tun__pm
  &gt; java.lang.RuntimeException: Invalid
  &gt; resource : tun__pm    at
  &gt; com.sun.enterprise.connectors.ConnectorRuntime.lookupDataSourceInDAS(ConnectorRuntime.java:539)
  &gt;   at
  &gt; com.sun.enterprise.connectors.ConnectorRuntime.lookupPMResource(ConnectorRuntime.java:468)
  &gt;   at
  &gt; org.glassfish.persistence.common.PersistenceHelper.lookupPMResource(PersistenceHelper.java:63)
  &gt;   at
  &gt; org.glassfish.persistence.jpa.ProviderContainerContractInfoBase.lookupDataSource(ProviderContainerContractInfoBase.java:71)
  &gt;   at
  &gt; org.glassfish.persistence.jpa.PersistenceUnitInfoImpl.&lt;init&gt;(PersistenceUnitInfoImpl.java:108)
  &gt;   at
  &gt; org.glassfish.persistence.jpa.PersistenceUnitLoader.loadPU(PersistenceUnitLoader.java:154)
  &gt;   at
  &gt; org.glassfish.persistence.jpa.PersistenceUnitLoader.&lt;init&gt;(PersistenceUnitLoader.java:119)
  &gt;   at
  &gt; org.glassfish.persistence.jpa.JPADeployer$1.visitPUD(JPADeployer.java:213)
  &gt;   at
  &gt; org.glassfish.persistence.jpa.JPADeployer$PersistenceUnitDescriptorIterator.iteratePUDs(JPADeployer.java:486)
  &gt;   at
  &gt; org.glassfish.persistence.jpa.JPADeployer.createEMFs(JPADeployer.java:220)
  &gt;   at
  &gt; org.glassfish.persistence.jpa.JPADeployer.prepare(JPADeployer.java:166)
  &gt;   at
  &gt; com.sun.enterprise.v3.server.ApplicationLifecycle.prepareModule(ApplicationLifecycle.java:870)
  &gt;   at
  &gt; com.sun.enterprise.v3.server.ApplicationLifecycle.deploy(ApplicationLifecycle.java:410)
  &gt;   at
  &gt; com.sun.enterprise.v3.server.ApplicationLifecycle.deploy(ApplicationLifecycle.java:240)
  &gt;   at
  &gt; org.glassfish.deployment.admin.DeployCommand.execute(DeployCommand.java:370)
  &gt;   at
  &gt; com.sun.enterprise.v3.admin.CommandRunnerImpl$1.execute(CommandRunnerImpl.java:355)
  &gt;   at
  &gt; com.sun.enterprise.v3.admin.CommandRunnerImpl.doCommand(CommandRunnerImpl.java:370)
  &gt;   at
  &gt; com.sun.enterprise.v3.admin.CommandRunnerImpl.doCommand(CommandRunnerImpl.java:1067)
  &gt;   at
  &gt; com.sun.enterprise.v3.admin.CommandRunnerImpl.access$1200(CommandRunnerImpl.java:96)
  &gt;   at
  &gt; com.sun.enterprise.v3.admin.CommandRunnerImpl$ExecutionContext.execute(CommandRunnerImpl.java:1247)
  &gt;   at
  &gt; com.sun.enterprise.v3.admin.CommandRunnerImpl$ExecutionContext.execute(CommandRunnerImpl.java:1235)
  &gt;   at
  &gt; org.glassfish.admingui.common.util.LocalDeploymentFacility$LocalDFCommandRunner.run(LocalDeploymentFacility.java:143)
  &gt;   at
  &gt; org.glassfish.deployment.client.AbstractDeploymentFacility.deploy(AbstractDeploymentFacility.java:406)
  &gt;   at
  &gt; org.glassfish.admingui.common.util.DeployUtil.invokeDeploymentFacility(DeployUtil.java:100)
  &gt;   at
  &gt; org.glassfish.admingui.common.util.DeployUtil.deploy(DeployUtil.java:76)
  &gt;   at
  &gt; org.glassfish.admingui.common.handlers.DeploymentHandler.deploy(DeploymentHandler.java:191)
  &gt;   at
  &gt; sun.reflect.NativeMethodAccessorImpl.invoke0(Native
  &gt; Method)   at
  &gt; sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
  &gt;   at
  &gt; sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
  &gt;   at
  &gt; java.lang.reflect.Method.invoke(Method.java:597)
  &gt;   at
  &gt; com.sun.jsftemplating.layout.descriptors.handler.Handler.invoke(Handler.java:442)
  &gt;   at
  &gt; com.sun.jsftemplating.layout.descriptors.LayoutElementBase.dispatchHandlers(LayoutElementBase.java:420)
  &gt;   at
  &gt; com.sun.jsftemplating.layout.descriptors.LayoutElementBase.dispatchHandlers(LayoutElementBase.java:394)
  &gt;   at
  &gt; com.sun.jsftemplating.layout.event.CommandActionListener.invokeCommandHandlers(CommandActionListener.java:150)
  &gt;   at
  &gt; com.sun.jsftemplating.layout.event.CommandActionListener.processAction(CommandActionListener.java:98)
  &gt;   at
  &gt; javax.faces.event.ActionEvent.processListener(ActionEvent.java:88)
  &gt;   at
  &gt; javax.faces.component.UIComponentBase.broadcast(UIComponentBase.java:769)
  &gt;   at
  &gt; javax.faces.component.UICommand.broadcast(UICommand.java:300)
  &gt;   at
  &gt; com.sun.webui.jsf.component.WebuiCommand.broadcast(WebuiCommand.java:166)
  &gt;   at
  &gt; javax.faces.component.UIViewRoot.broadcastEvents(UIViewRoot.java:794)
  &gt;   at
  &gt; javax.faces.component.UIViewRoot.processApplication(UIViewRoot.java:1259)
  &gt;   at
  &gt; com.sun.faces.lifecycle.InvokeApplicationPhase.execute(InvokeApplicationPhase.java:81)
  &gt;   at
  &gt; com.sun.faces.lifecycle.Phase.doPhase(Phase.java:101)
  &gt;   at
  &gt; com.sun.faces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:118)
  &gt;   at
  &gt; javax.faces.webapp.FacesServlet.service(FacesServlet.java:409)
  &gt;   at
  &gt; org.apache.catalina.core.StandardWrapper.service(StandardWrapper.java:1534)
  &gt;   at
  &gt; org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:343)
  &gt;   at
  &gt; org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:215)
  &gt;   at
  &gt; com.sun.webui.jsf.util.UploadFilter.doFilter(UploadFilter.java:223)
  &gt;   at
  &gt; org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:256)
  &gt;   at
  &gt; org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:215)
  &gt;   at
  &gt; org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:279)
  &gt;   at
  &gt; org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:175)
  &gt;   at
  &gt; org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:655)
  &gt;   at
  &gt; org.apache.catalina.core.StandardPipeline.doChainInvoke(StandardPipeline.java:600)
  &gt;   at
  &gt; com.sun.enterprise.web.WebPipeline.invoke(WebPipeline.java:96)
  &gt;   at
  &gt; com.sun.enterprise.web.PESessionLockingStandardPipeline.invoke(PESessionLockingStandardPipeline.java:91)
  &gt;   at
  &gt; org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:162)
  &gt;   at
  &gt; org.apache.catalina.connector.CoyoteAdapter.doService(CoyoteAdapter.java:326)
  &gt;   at
  &gt; org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:227)
  &gt;   at
  &gt; com.sun.enterprise.v3.services.impl.ContainerMapper.service(ContainerMapper.java:228)
  &gt;   at
  &gt; com.sun.grizzly.http.ProcessorTask.invokeAdapter(ProcessorTask.java:822)
  &gt;   at
  &gt; com.sun.grizzly.http.ProcessorTask.doProcess(ProcessorTask.java:719)
  &gt;   at
  &gt; com.sun.grizzly.http.ProcessorTask.process(ProcessorTask.java:1013)
  &gt;   at
  &gt; com.sun.grizzly.http.DefaultProtocolFilter.execute(DefaultProtocolFilter.java:225)
  &gt;   at
  &gt; com.sun.grizzly.DefaultProtocolChain.executeProtocolFilter(DefaultProtocolChain.java:137)
  &gt;   at
  &gt; com.sun.grizzly.DefaultProtocolChain.execute(DefaultProtocolChain.java:104)
  &gt;   at
  &gt; com.sun.grizzly.DefaultProtocolChain.execute(DefaultProtocolChain.java:90)
  &gt;   at
  &gt; com.sun.grizzly.http.HttpProtocolChain.execute(HttpProtocolChain.java:79)
  &gt;   at
  &gt; com.sun.grizzly.ProtocolChainContextTask.doCall(ProtocolChainContextTask.java:54)
  &gt;   at
  &gt; com.sun.grizzly.SelectionKeyContextTask.call(SelectionKeyContextTask.java:59)
  &gt;   at
  &gt; com.sun.grizzly.ContextTask.run(ContextTask.java:71)
  &gt;   at
  &gt; com.sun.grizzly.util.AbstractThreadPool$Worker.doWork(AbstractThreadPool.java:532)
  &gt;   at
  &gt; com.sun.grizzly.util.AbstractThreadPool$Worker.run(AbstractThreadPool.java:513)
  &gt;   at
  &gt; java.lang.Thread.run(Thread.java:680)
  &gt; Caused by:
  &gt; com.sun.appserv.connectors.internal.api.ConnectorRuntimeException:
  &gt; Invalid resource : tun__pm    at
  &gt; com.sun.enterprise.connectors.service.ConnectorResourceAdminServiceImpl$MyDataSource.validateResource(ConnectorResourceAdminServiceImpl.java:272)
  &gt;   at
  &gt; com.sun.enterprise.connectors.service.ConnectorResourceAdminServiceImpl$MyDataSource.setResourceInfo(ConnectorResourceAdminServiceImpl.java:253)
  &gt;   at
  &gt; com.sun.enterprise.connectors.service.ConnectorResourceAdminServiceImpl.lookupDataSourceInDAS(ConnectorResourceAdminServiceImpl.java:243)
  &gt;   at
  &gt; com.sun.enterprise.connectors.ConnectorRuntime.lookupDataSourceInDAS(ConnectorRuntime.java:537)
  &gt;   ... 74 more |#]
  &gt; 
  &gt; [#|2011-04-30T19:50:05.238+0100|SEVERE|glassfish3.1|javax.enterprise.system.tools.admin.org.glassfish.deployment.admin|_ThreadID=84;_ThreadName=Thread-3;|Exception
  &gt; while preparing the app : Invalid
  &gt; resource : tun__pm
  &gt; com.sun.appserv.connectors.internal.api.ConnectorRuntimeException:
  &gt; Invalid resource : tun__pm    at
  &gt; com.sun.enterprise.connectors.service.ConnectorResourceAdminServiceImpl$MyDataSource.validateResource(ConnectorResourceAdminServiceImpl.java:272)
  &gt;   at
  &gt; com.sun.enterprise.connectors.service.ConnectorResourceAdminServiceImpl$MyDataSource.setResourceInfo(ConnectorResourceAdminServiceImpl.java:253)
  &gt;   at
  &gt; com.sun.enterprise.connectors.service.ConnectorResourceAdminServiceImpl.lookupDataSourceInDAS(ConnectorResourceAdminServiceImpl.java:243)
  &gt;   at
  &gt; com.sun.enterprise.connectors.ConnectorRuntime.lookupDataSourceInDAS(ConnectorRuntime.java:537)
  &gt;   at
  &gt; com.sun.enterprise.connectors.ConnectorRuntime.lookupPMResource(ConnectorRuntime.java:468)
  &gt;   at
  &gt; org.glassfish.persistence.common.PersistenceHelper.lookupPMResource(PersistenceHelper.java:63)
  &gt;   at
  &gt; org.glassfish.persistence.jpa.ProviderContainerContractInfoBase.lookupDataSource(ProviderContainerContractInfoBase.java:71)
  &gt;   at
  &gt; org.glassfish.persistence.jpa.PersistenceUnitInfoImpl.&lt;init&gt;(PersistenceUnitInfoImpl.java:108)
  &gt;   at
  &gt; org.glassfish.persistence.jpa.PersistenceUnitLoader.loadPU(PersistenceUnitLoader.java:154)
  &gt;   at
  &gt; org.glassfish.persistence.jpa.PersistenceUnitLoader.&lt;init&gt;(PersistenceUnitLoader.java:119)
  &gt;   at
  &gt; org.glassfish.persistence.jpa.JPADeployer$1.visitPUD(JPADeployer.java:213)
  &gt;   at
  &gt; org.glassfish.persistence.jpa.JPADeployer$PersistenceUnitDescriptorIterator.iteratePUDs(JPADeployer.java:486)
  &gt;   at
  &gt; org.glassfish.persistence.jpa.JPADeployer.createEMFs(JPADeployer.java:220)
  &gt;   at
  &gt; org.glassfish.persistence.jpa.JPADeployer.prepare(JPADeployer.java:166)
  &gt;   at
  &gt; com.sun.enterprise.v3.server.ApplicationLifecycle.prepareModule(ApplicationLifecycle.java:870)
  &gt;   at
  &gt; com.sun.enterprise.v3.server.ApplicationLifecycle.deploy(ApplicationLifecycle.java:410)
  &gt;   at
  &gt; com.sun.enterprise.v3.server.ApplicationLifecycle.deploy(ApplicationLifecycle.java:240)
  &gt;   at
  &gt; org.glassfish.deployment.admin.DeployCommand.execute(DeployCommand.java:370)
  &gt;   at
  &gt; com.sun.enterprise.v3.admin.CommandRunnerImpl$1.execute(CommandRunnerImpl.java:355)
  &gt;   at
  &gt; com.sun.enterprise.v3.admin.CommandRunnerImpl.doCommand(CommandRunnerImpl.java:370)
  &gt;   at
  &gt; com.sun.enterprise.v3.admin.CommandRunnerImpl.doCommand(CommandRunnerImpl.java:1067)
  &gt;   at
  &gt; com.sun.enterprise.v3.admin.CommandRunnerImpl.access$1200(CommandRunnerImpl.java:96)
  &gt;   at
  &gt; com.sun.enterprise.v3.admin.CommandRunnerImpl$ExecutionContext.execute(CommandRunnerImpl.java:1247)
  &gt;   at
  &gt; com.sun.enterprise.v3.admin.CommandRunnerImpl$ExecutionContext.execute(CommandRunnerImpl.java:1235)
  &gt;   at
  &gt; org.glassfish.admingui.common.util.LocalDeploymentFacility$LocalDFCommandRunner.run(LocalDeploymentFacility.java:143)
  &gt;   at
  &gt; org.glassfish.deployment.client.AbstractDeploymentFacility.deploy(AbstractDeploymentFacility.java:406)
  &gt;   at
  &gt; org.glassfish.admingui.common.util.DeployUtil.invokeDeploymentFacility(DeployUtil.java:100)
  &gt;   at
  &gt; org.glassfish.admingui.common.util.DeployUtil.deploy(DeployUtil.java:76)
  &gt;   at
  &gt; org.glassfish.admingui.common.handlers.DeploymentHandler.deploy(DeploymentHandler.java:191)
  &gt;   at
  &gt; sun.reflect.NativeMethodAccessorImpl.invoke0(Native
  &gt; Method)   at
  &gt; sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
  &gt;   at
  &gt; sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
  &gt;   at
  &gt; java.lang.reflect.Method.invoke(Method.java:597)
  &gt;   at
  &gt; com.sun.jsftemplating.layout.descriptors.handler.Handler.invoke(Handler.java:442)
  &gt;   at
  &gt; com.sun.jsftemplating.layout.descriptors.LayoutElementBase.dispatchHandlers(LayoutElementBase.java:420)
  &gt;   at
  &gt; com.sun.jsftemplating.layout.descriptors.LayoutElementBase.dispatchHandlers(LayoutElementBase.java:394)
  &gt;   at
  &gt; com.sun.jsftemplating.layout.event.CommandActionListener.invokeCommandHandlers(CommandActionListener.java:150)
  &gt;   at
  &gt; com.sun.jsftemplating.layout.event.CommandActionListener.processAction(CommandActionListener.java:98)
  &gt;   at
  &gt; javax.faces.event.ActionEvent.processListener(ActionEvent.java:88)
  &gt;   at
  &gt; javax.faces.component.UIComponentBase.broadcast(UIComponentBase.java:769)
  &gt;   at
  &gt; javax.faces.component.UICommand.broadcast(UICommand.java:300)
  &gt;   at
  &gt; com.sun.webui.jsf.component.WebuiCommand.broadcast(WebuiCommand.java:166)
  &gt;   at
  &gt; javax.faces.component.UIViewRoot.broadcastEvents(UIViewRoot.java:794)
  &gt;   at
  &gt; javax.faces.component.UIViewRoot.processApplication(UIViewRoot.java:1259)
  &gt;   at
  &gt; com.sun.faces.lifecycle.InvokeApplicationPhase.execute(InvokeApplicationPhase.java:81)
  &gt;   at
  &gt; com.sun.faces.lifecycle.Phase.doPhase(Phase.java:101)
  &gt;   at
  &gt; com.sun.faces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:118)
  &gt;   at
  &gt; javax.faces.webapp.FacesServlet.service(FacesServlet.java:409)
  &gt;   at
  &gt; org.apache.catalina.core.StandardWrapper.service(StandardWrapper.java:1534)
  &gt;   at
  &gt; org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:343)
  &gt;   at
  &gt; org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:215)
  &gt;   at
  &gt; com.sun.webui.jsf.util.UploadFilter.doFilter(UploadFilter.java:223)
  &gt;   at
  &gt; org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:256)
  &gt;   at
  &gt; org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:215)
  &gt;   at
  &gt; org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:279)
  &gt;   at
  &gt; org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:175)
  &gt;   at
  &gt; org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:655)
  &gt;   at
  &gt; org.apache.catalina.core.StandardPipeline.doChainInvoke(StandardPipeline.java:600)
  &gt;   at
  &gt; com.sun.enterprise.web.WebPipeline.invoke(WebPipeline.java:96)
  &gt;   at
  &gt; com.sun.enterprise.web.PESessionLockingStandardPipeline.invoke(PESessionLockingStandardPipeline.java:91)
  &gt;   at
  &gt; org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:162)
  &gt;   at
  &gt; org.apache.catalina.connector.CoyoteAdapter.doService(CoyoteAdapter.java:326)
  &gt;   at
  &gt; org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:227)
  &gt;   at
  &gt; com.sun.enterprise.v3.services.impl.ContainerMapper.service(ContainerMapper.java:228)
  &gt;   at
  &gt; com.sun.grizzly.http.ProcessorTask.invokeAdapter(ProcessorTask.java:822)
  &gt;   at
  &gt; com.sun.grizzly.http.ProcessorTask.doProcess(ProcessorTask.java:719)
  &gt;   at
  &gt; com.sun.grizzly.http.ProcessorTask.process(ProcessorTask.java:1013)
  &gt;   at
  &gt; com.sun.grizzly.http.DefaultProtocolFilter.execute(DefaultProtocolFilter.java:225)
  &gt;   at
  &gt; com.sun.grizzly.DefaultProtocolChain.executeProtocolFilter(DefaultProtocolChain.java:137)
  &gt;   at
  &gt; com.sun.grizzly.DefaultProtocolChain.execute(DefaultProtocolChain.java:104)
  &gt;   at
  &gt; com.sun.grizzly.DefaultProtocolChain.execute(DefaultProtocolChain.java:90)
  &gt;   at
  &gt; com.sun.grizzly.http.HttpProtocolChain.execute(HttpProtocolChain.java:79)
  &gt;   at
  &gt; com.sun.grizzly.ProtocolChainContextTask.doCall(ProtocolChainContextTask.java:54)
  &gt;   at
  &gt; com.sun.grizzly.SelectionKeyContextTask.call(SelectionKeyContextTask.java:59)
  &gt;   at
  &gt; com.sun.grizzly.ContextTask.run(ContextTask.java:71)
  &gt;   at
  &gt; com.sun.grizzly.util.AbstractThreadPool$Worker.doWork(AbstractThreadPool.java:532)
  &gt;   at
  &gt; com.sun.grizzly.util.AbstractThreadPool$Worker.run(AbstractThreadPool.java:513)
  &gt;   at
  &gt; java.lang.Thread.run(Thread.java:680)
  </code></pre>
  
  <p>i don't know what is <code>tun__pm</code> but tun is the name of the database connection in netbeans .Should i do something in glassfish for the database connection ? mysql is working ..</p>