10 Replies Latest reply on Jun 3, 2009 2:17 PM by visakh m

    Deploy fails under Tomcat on: 'Could not find datasource'

    Michal Rost Newbie

      Hi,
      i used seam-gen to generate WAR application, called 'market'. I created two separated deploy-jar lists one for jboss and another (with all required jars like asm, dom4j, jta etc.) for tomcat. And I manually rewrote build.xml in order to deploy application on both servers (JBoss AS and Tomcat6). Deploy for JBoss AS works fine, but deploy for Tomcat fails on this exception:



      1.11.2008 12:58:41 org.apache.catalina.core.StandardContext listenerStart
      SEVERE: Exception sending context initialized event to listener instance of class org.jboss.seam.servlet.SeamListener
      org.jboss.seam.InstantiationException: Could not instantiate Seam component: marketEntityManagerFactory
           at org.jboss.seam.Component.newInstance(Component.java:2066)
           at org.jboss.seam.contexts.Contexts.startup(Contexts.java:304)
           at org.jboss.seam.contexts.Contexts.startup(Contexts.java:278)
           at org.jboss.seam.contexts.ServletLifecycle.endInitialization(ServletLifecycle.java:112)
           at org.jboss.seam.init.Initialization.init(Initialization.java:727)
           at org.jboss.seam.servlet.SeamListener.contextInitialized(SeamListener.java:34)
           at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:3843)
           at org.apache.catalina.core.StandardContext.start(StandardContext.java:4342)
           at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:791)
           at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:771)
           at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:525)
           at org.apache.catalina.startup.HostConfig.deployDirectory(HostConfig.java:926)
           at org.apache.catalina.startup.HostConfig.deployDirectories(HostConfig.java:889)
           at org.apache.catalina.startup.HostConfig.deployApps(HostConfig.java:492)
           at org.apache.catalina.startup.HostConfig.check(HostConfig.java:1217)
           at org.apache.catalina.startup.HostConfig.lifecycleEvent(HostConfig.java:293)
           at org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(LifecycleSupport.java:117)
           at org.apache.catalina.core.ContainerBase.backgroundProcess(ContainerBase.java:1337)
           at org.apache.catalina.core.ContainerBase$ContainerBackgroundProcessor.processChildren(ContainerBase.java:1601)
           at org.apache.catalina.core.ContainerBase$ContainerBackgroundProcessor.processChildren(ContainerBase.java:1610)
           at org.apache.catalina.core.ContainerBase$ContainerBackgroundProcessor.run(ContainerBase.java:1590)
           at java.lang.Thread.run(Thread.java:619)
      Caused by: javax.persistence.PersistenceException: org.hibernate.HibernateException: Could not find datasource
           at org.hibernate.ejb.Ejb3Configuration.buildEntityManagerFactory(Ejb3Configuration.java:663)
           at org.hibernate.ejb.HibernatePersistence.createEntityManagerFactory(HibernatePersistence.java:121)
           at javax.persistence.Persistence.createEntityManagerFactory(Persistence.java:52)
           at javax.persistence.Persistence.createEntityManagerFactory(Persistence.java:34)
           at org.jboss.seam.persistence.EntityManagerFactory.createEntityManagerFactory(EntityManagerFactory.java:81)
           at org.jboss.seam.persistence.EntityManagerFactory.startup(EntityManagerFactory.java:50)
           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:597)
           at org.jboss.seam.util.Reflections.invoke(Reflections.java:22)
           at org.jboss.seam.util.Reflections.invokeAndWrap(Reflections.java:138)
           at org.jboss.seam.Component.callComponentMethod(Component.java:2179)
           at org.jboss.seam.Component.callCreateMethod(Component.java:2094)
           at org.jboss.seam.Component.newInstance(Component.java:2054)
           ... 21 more
      Caused by: org.hibernate.HibernateException: Could not find datasource
           at org.hibernate.connection.DatasourceConnectionProvider.configure(DatasourceConnectionProvider.java:56)
           at org.hibernate.connection.ConnectionProviderFactory.newConnectionProvider(ConnectionProviderFactory.java:124)
           at org.hibernate.ejb.InjectionSettingsFactory.createConnectionProvider(InjectionSettingsFactory.java:29)
           at org.hibernate.cfg.SettingsFactory.buildSettings(SettingsFactory.java:62)
           at org.hibernate.cfg.Configuration.buildSettings(Configuration.java:2009)
           at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1292)
           at org.hibernate.cfg.AnnotationConfiguration.buildSessionFactory(AnnotationConfiguration.java:918)
           at org.hibernate.ejb.Ejb3Configuration.buildEntityManagerFactory(Ejb3Configuration.java:656)
           ... 35 more
      Caused by: javax.naming.NameNotFoundException: Name marketDataSource is not bound in this Context
           at org.apache.naming.NamingContext.lookup(NamingContext.java:770)
           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:140)
           at org.apache.naming.NamingContext.lookup(NamingContext.java:781)
           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 org.apache.naming.SelectorContext.lookup(SelectorContext.java:137)
           at javax.naming.InitialContext.lookup(InitialContext.java:392)
           at org.hibernate.connection.DatasourceConnectionProvider.configure(DatasourceConnectionProvider.java:52)
           ... 42 more
      1.11.2008 12:58:41 org.apache.catalina.core.StandardContext start
      SEVERE: Error listenerStart
      1.11.2008 12:58:41 org.apache.catalina.core.StandardContext start
      SEVERE: Context [/market.war] startup failed due to previous errors



      I think I know where problem should be, for JBoss there is a file called market-ds.xml, which in my case looks like this:


      <?xml version="1.0" encoding="UTF-8"?>
      
      <!DOCTYPE datasources
          PUBLIC "-//JBoss//DTD JBOSS JCA Config 1.5//EN"
          "http://www.jboss.org/j2ee/dtd/jboss-ds_1_5.dtd">
          
      <datasources>
         
         <local-tx-datasource>
            <jndi-name>marketDatasource</jndi-name>
            <connection-url>jdbc:mysql:///market</connection-url>
            <driver-class>com.mysql.jdbc.Driver</driver-class>
            <user-name>root</user-name>
            <password></password>
         </local-tx-datasource>
          
      </datasources>



      I was wondering how to tell tomcat, where should it search for data source and i've found configuration file context.xml in seam JPA example. So now I deploy this context.xml under
      tomcat6.dir/webapps/market.war/META-INF/context.xml
      and in looks like this:



      <Context path="/market" docBase="market"
              debug="5" reloadable="true" crossContext="true">
      
        <Resource name="market" auth="Container" type="javax.sql.DataSource"
                     maxActive="100" maxIdle="30" maxWait="10000"
                     username="root" password="" driverClassName="com.mysql.jdbc.Driver"
                     url="jdbc:mysql:///market"/>
      </Context>



      and to web.xml i've added:


        <resource-ref>
            <description>DB Connection</description>
            <res-ref-name>jdbc/market</res-ref-name>
            <res-type>javax.sql.DataSource</res-type>
            <res-auth>Container</res-auth>
        </resource-ref>




      But it won't help, still same error, when i change resource name to marketDataSource it won't change. This  is my persistence.xml file:



      <?xml version="1.0" encoding="UTF-8"?>
      <!-- Persistence deployment descriptor for dev profile -->
      <persistence xmlns="http://java.sun.com/xml/ns/persistence" 
                   xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
                   xsi:schemaLocation="http://java.sun.com/xml/ns/persistence http://java.sun.com/xml/ns/persistence/persistence_1_0.xsd" 
                   version="1.0">
                   
         <persistence-unit name="market" transaction-type="RESOURCE_LOCAL">
            <provider>org.hibernate.ejb.HibernatePersistence</provider>
            <jta-data-source>java:comp/env/jdbc/marketDataSource</jta-data-source>
            <properties>
               <property name="hibernate.dialect" value="org.hibernate.dialect.MySQLDialect"/>
               <property name="hibernate.hbm2ddl.auto" value="update"/>
               <property name="hibernate.show_sql" value="true"/>
               <property name="hibernate.format_sql" value="true"/>
            <!--   <property name="hibernate.transaction.manager_lookup_class" value="org.hibernate.transaction.JBossTransactionManagerLookup"/> -->
            </properties>
         </persistence-unit>
          
      </persistence>



      if there is only marketDataSource instead of java:comp/env/jdbc/marketDataSource (like in JPA sample) or JTA instead of RESOURCE_LOCAL the problem remains again same :(
      And finally this is my components.xml



      <?xml version="1.0" encoding="UTF-8"?>
      <components xmlns="http://jboss.com/products/seam/components"
                  xmlns:core="http://jboss.com/products/seam/core"
                  xmlns:persistence="http://jboss.com/products/seam/persistence"
                  xmlns:drools="http://jboss.com/products/seam/drools"
                  xmlns:bpm="http://jboss.com/products/seam/bpm"
                  xmlns:security="http://jboss.com/products/seam/security"
                  xmlns:mail="http://jboss.com/products/seam/mail"
                  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
                  xsi:schemaLocation=
                      "http://jboss.com/products/seam/core http://jboss.com/products/seam/core-2.1.xsd 
                       http://jboss.com/products/seam/persistence http://jboss.com/products/seam/persistence-2.1.xsd 
                       http://jboss.com/products/seam/drools http://jboss.com/products/seam/drools-2.1.xsd
                       http://jboss.com/products/seam/bpm http://jboss.com/products/seam/bpm-2.1.xsd
                       http://jboss.com/products/seam/security http://jboss.com/products/seam/security-2.1.xsd
                       http://jboss.com/products/seam/mail http://jboss.com/products/seam/mail-2.1.xsd
                       http://jboss.com/products/seam/components http://jboss.com/products/seam/components-2.1.xsd">
      
         <core:init debug="true" jndi-pattern="market/#{ejbName}/local"/>
           
         <core:manager concurrent-request-timeout="500" 
                       conversation-timeout="120000" 
                       conversation-id-parameter="cid"
                       parent-conversation-id-parameter="pid"/>
       
         <persistence:entity-manager-factory name="marketEntityManagerFactory" 
                            persistence-unit-name="market"/>
      
         <persistence:managed-persistence-context name="entityManager"
                                           auto-create="true"
                                entity-manager-factory="#{marketEntityManagerFactory}"/>
         
         <drools:rule-base name="securityRules">
            <drools:rule-files><value>/security.drl</value></drools:rule-files>
         </drools:rule-base>
      
         <security:rule-based-permission-resolver security-rules="#{securityRules}"/> 
      
         <security:identity authenticate-method="#{authenticator.authenticate}" remember-me="true"/>
                                    
         <event type="org.jboss.seam.security.notLoggedIn">
            <action execute="#{redirect.captureCurrentView}"/>
         </event>
         <event type="org.jboss.seam.security.loginSuccessful">
            <action execute="#{redirect.returnToCapturedView}"/>
         </event>
         
         <mail:mail-session host="localhost" port="2525" username="test" password="test" />
         
      </components>



      if i change the components.xml code to code like in JPA seam example to:


      <?xml version="1.0" encoding="UTF-8"?>
      <components xmlns="http://jboss.com/products/seam/components"
                  xmlns:core="http://jboss.com/products/seam/core"
                  xmlns:persistence="http://jboss.com/products/seam/persistence"
                  xmlns:transaction="http://jboss.com/products/seam/transaction"
                  xmlns:drools="http://jboss.com/products/seam/drools"
                  xmlns:bpm="http://jboss.com/products/seam/bpm"
                  xmlns:security="http://jboss.com/products/seam/security"
                  xmlns:mail="http://jboss.com/products/seam/mail"
                  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
                  xsi:schemaLocation=
                      "http://jboss.com/products/seam/core http://jboss.com/products/seam/core-2.1.xsd 
                       http://jboss.com/products/seam/persistence http://jboss.com/products/seam/persistence-2.1.xsd 
                       http://jboss.com/products/seam/drools http://jboss.com/products/seam/drools-2.1.xsd
                       http://jboss.com/products/seam/bpm http://jboss.com/products/seam/bpm-2.1.xsd
                       http://jboss.com/products/seam/security http://jboss.com/products/seam/security-2.1.xsd
                       http://jboss.com/products/seam/mail http://jboss.com/products/seam/mail-2.1.xsd
                       http://jboss.com/products/seam/components http://jboss.com/products/seam/components-2.1.xsd">
      
         <core:init debug="true" jndi-pattern="market/#{ejbName}/local"/>
           
         <core:manager concurrent-request-timeout="500" 
                       conversation-timeout="120000" 
                       conversation-id-parameter="cid"
                       parent-conversation-id-parameter="pid"/>
      
         <transaction:entity-transaction entity-manager="#{entityManager}"/>
      
         <persistence:entity-manager-factory name="marketEntityManagerFactory"/>
      
         <persistence:managed-persistence-context name="entityManager"
                                           auto-create="true"
                                entity-manager-factory="#{marketEntityManagerFactory}"/>
         
         <drools:rule-base name="securityRules">
            <drools:rule-files><value>/security.drl</value></drools:rule-files>
         </drools:rule-base>
      
         <security:rule-based-permission-resolver security-rules="#{securityRules}"/> 
      
         <security:identity authenticate-method="#{authenticator.authenticate}" remember-me="true"/>
                                    
         <event type="org.jboss.seam.security.notLoggedIn">
            <action execute="#{redirect.captureCurrentView}"/>
         </event>
         <event type="org.jboss.seam.security.loginSuccessful">
            <action execute="#{redirect.returnToCapturedView}"/>
         </event>
         
         <mail:mail-session host="localhost" port="2525" username="test" password="test" />
           
      </components>



      the error code will now change to:


      1.11.2008 13:40:53 org.apache.catalina.core.StandardContext listenerStart
      SEVERE: Exception sending context initialized event to listener instance of class org.jboss.seam.servlet.SeamListener
      org.jboss.seam.InstantiationException: Could not instantiate Seam component: marketEntityManagerFactory
           at org.jboss.seam.Component.newInstance(Component.java:2066)
           at org.jboss.seam.contexts.Contexts.startup(Contexts.java:304)
           at org.jboss.seam.contexts.Contexts.startup(Contexts.java:278)
           at org.jboss.seam.contexts.ServletLifecycle.endInitialization(ServletLifecycle.java:112)
           at org.jboss.seam.init.Initialization.init(Initialization.java:727)
           at org.jboss.seam.servlet.SeamListener.contextInitialized(SeamListener.java:34)
           at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:3843)
           at org.apache.catalina.core.StandardContext.start(StandardContext.java:4342)
           at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:791)
           at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:771)
           at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:525)
           at org.apache.catalina.startup.HostConfig.deployDirectory(HostConfig.java:926)
           at org.apache.catalina.startup.HostConfig.deployDirectories(HostConfig.java:889)
           at org.apache.catalina.startup.HostConfig.deployApps(HostConfig.java:492)
           at org.apache.catalina.startup.HostConfig.start(HostConfig.java:1149)
           at org.apache.catalina.startup.HostConfig.lifecycleEvent(HostConfig.java:311)
           at org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(LifecycleSupport.java:117)
           at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1053)
           at org.apache.catalina.core.StandardHost.start(StandardHost.java:719)
           at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1045)
           at org.apache.catalina.core.StandardEngine.start(StandardEngine.java:443)
           at org.apache.catalina.core.StandardService.start(StandardService.java:516)
           at org.apache.catalina.core.StandardServer.start(StandardServer.java:710)
           at org.apache.catalina.startup.Catalina.start(Catalina.java:578)
           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:597)
           at org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:288)
           at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:413)
      Caused by: javax.persistence.PersistenceException: No Persistence provider for EntityManager named marketEntityManagerFactory
           at javax.persistence.Persistence.createEntityManagerFactory(Persistence.java:56)
           at javax.persistence.Persistence.createEntityManagerFactory(Persistence.java:34)
           at org.jboss.seam.persistence.EntityManagerFactory.createEntityManagerFactory(EntityManagerFactory.java:81)
           at org.jboss.seam.persistence.EntityManagerFactory.startup(EntityManagerFactory.java:50)
           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:597)
           at org.jboss.seam.util.Reflections.invoke(Reflections.java:22)
           at org.jboss.seam.util.Reflections.invokeAndWrap(Reflections.java:138)
           at org.jboss.seam.Component.callComponentMethod(Component.java:2179)
           at org.jboss.seam.Component.callCreateMethod(Component.java:2094)
           at org.jboss.seam.Component.newInstance(Component.java:2054)
           ... 29 more
      1.11.2008 13:40:53 org.apache.catalina.core.StandardContext start
      SEVERE: Error listenerStart
      1.11.2008 13:40:53 org.apache.catalina.core.StandardContext start
      SEVERE: Context [/market.war] startup failed due to previous errors
      1.11.2008 13:40:53 org.apache.coyote.http11.Http11Protocol start
      INFO: Starting Coyote HTTP/1.1 on http-8080
      1.11.2008 13:40:53 org.apache.jk.common.ChannelSocket init
      INFO: JK: ajp13 listening on /0.0.0.0:8009
      1.11.2008 13:40:53 org.apache.jk.server.JkMain start
      INFO: Jk running ID=0 time=0/115  config=null
      1.11.2008 13:40:53 org.apache.catalina.startup.Catalina start
      INFO: Server startup in 4393 ms



      Have somebody faced the same problem, could someone help me, please :(.


        • 1. Re: Deploy fails under Tomcat on: 'Could not find datasource'
          Michal Rost Newbie

          I'm apologizing, the whole error with data source was that in persistence.xml instead:



          <jta-data-source>java:comp/env/jdbc/marketDataSource</jta-data-source>




          must be same data source name as in context.xml, so:



          <jta-data-source>java:comp/env/jdbc/market</jta-data-source>




          the second error Could not instantiate Seam component: marketEntityManagerFactory is still present, only when i try to set transaction:entity-transaction entity-manager in components.xml, in other case the application will deploy without any error, but it won't run :(


          I receive message from browser:



          Firefox has detected that the server is redirecting the request for this address in a way that will never complete.


          • 2. Re: Deploy fails under Tomcat on: 'Could not find datasource'
            Tathagat Tathagat Newbie

            Hi.
            Did you find a solution to this problem.


            Many thanks
            Tathagat

            • 3. Re: Deploy fails under Tomcat on: 'Could not find datasource'
              Karl Beowulph Newbie

              I had this problem until I modified my {CATALINA}/conf/context.xml file to include the line:


              <Listener className="org.jboss.embedded.tomcat.WebinfScanner" />
              



              Now I'm getting the following:


              -Jun-2009 2:11:29 PM org.apache.tomcat.util.digester.SetPropertiesRule begin
              WARNING: [SetPropertiesRule]{Server/Service/Engine/Host/Context} Setting property 'source' to 'org.eclipse.jst.jee.server:tomCatTestProj' did not find a matching property.
              2-Jun-2009 2:11:29 PM org.apache.catalina.core.AprLifecycleListener init
              INFO: The APR based Apache Tomcat Native library which allows optimal performance in production environments was not found on the java.library.path: C:\Program Files\Java\jre1.5.0_14\bin;.;C:\WINDOWS\system32;C:\WINDOWS;C:/Program Files/Java/jre1.5.0_14/bin/client;C:/Program Files/Java/jre1.5.0_14/bin;C:\PROGRA~1\Serena\vm\win32\bin;C:\PROGRA~1\Serena\vm\common\bin\win32;C:\Oracle\Ora80\bin;C:\PVSW\BIN;C:\ORACLE\ORA81\BIN;C:\PROGRAM FILES\ORACLE\JRE\1.1.7\BIN;C:\WINDOWS\SYSTEM32;C:\WINDOWS;C:\WINDOWS\SYSTEM32\WBEM;C:\PROGRAM FILES\COMMON FILES\AUTODESK SHARED\;C:\PROGRAM FILES\TRUEARC\SHARED FILES;C:\ORACLE\ORA80\JDK\BIN;C:\PROGRAM FILES\DOCUMENTUM\SHARED;C:\Program Files\ABB\sidl\bin;C:\Program Files\ABB\bin;C:\Program Files\ABB\WS500\;C:\WS500ExtendedDialogs\;C:\WS500ExtendedDialogs\TeleUSE\bin;C:\WS500ExtendedDialogs\TeleUSE\server;C:\Program Files\IDM Computer Solutions\UltraEdit-32;C:\Program Files\Microsoft SQL Server\80\Tools\Binn\;C:\Program Files\Microsoft SQL Server\90\Tools\binn\;C:\Program Files\Microsoft SQL Server\90\DTS\Binn\;C:\Program Files\Microsoft SQL Server\90\Tools\Binn\VSShell\Common7\IDE\;C:\Program Files\Microsoft Visual Studio 8\Common7\IDE\PrivateAssemblies\;C:\opt\apache-ant-1.7.0\bin\;
              2-Jun-2009 2:11:29 PM org.apache.coyote.http11.Http11Protocol init
              INFO: Initializing Coyote HTTP/1.1 on http-8080
              2-Jun-2009 2:11:29 PM org.apache.catalina.startup.Catalina load
              INFO: Initialization processed in 729 ms
              2-Jun-2009 2:11:30 PM org.apache.catalina.core.StandardService start
              INFO: Starting service Catalina
              2-Jun-2009 2:11:30 PM org.apache.catalina.core.StandardEngine start
              INFO: Starting Servlet Engine: Apache Tomcat/6.0.18
              2-Jun-2009 2:11:30 PM org.apache.catalina.startup.DigesterFactory register
              WARNING: Could not get url for /javax/servlet/jsp/resources/jsp_2_1.xsd
              2-Jun-2009 2:11:30 PM org.apache.catalina.startup.DigesterFactory register
              WARNING: Could not get url for /javax/servlet/resources/j2ee_web_services_1_1.xsd
              2-Jun-2009 2:11:30 PM org.apache.catalina.startup.DigesterFactory register
              WARNING: Could not get url for /javax/servlet/jsp/resources/jsp_2_1.xsd
              2-Jun-2009 2:11:30 PM org.apache.catalina.startup.DigesterFactory register
              WARNING: Could not get url for /javax/servlet/resources/j2ee_web_services_1_1.xsd
              2-Jun-2009 2:11:31 PM org.apache.tomcat.util.modeler.Registry registerComponent
              SEVERE: Null component Catalina:type=JspMonitor,name=jsp,WebModule=//localhost/tomCatTestProj,J2EEApplication=none,J2EEServer=none
              java.lang.reflect.InvocationTargetException
                      at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
                      at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
                      at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
                      at java.lang.reflect.Method.invoke(Unknown Source)
                      at org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:288)
                      at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:413)
              Caused by: java.lang.RuntimeException: org.jboss.deployers.spi.DeploymentException: Unable to get VirtualFile for url: file:/C:/opt/apache-tomcat-6.0.18/wtpwebapps/tomCatTestProj/WEB-INF/lib/
                      at org.jboss.embedded.tomcat.WebinfScanner.lifecycleEvent(WebinfScanner.java:94)
                      at org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(LifecycleSupport.java:117)
                      at org.apache.catalina.core.StandardContext.start(StandardContext.java:4252)
                      at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1045)
                      at org.apache.catalina.core.StandardHost.start(StandardHost.java:719)
                      at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1045)
                      at org.apache.catalina.core.StandardEngine.start(StandardEngine.java:443)
                      at org.apache.catalina.core.StandardService.start(StandardService.java:516)
                      at org.apache.catalina.core.StandardServer.start(StandardServer.java:710)
                      at org.apache.catalina.startup.Catalina.start(Catalina.java:578)
                      ... 6 more
              Caused by: org.jboss.deployers.spi.DeploymentException: Unable to get VirtualFile for url: file:/C:/opt/apache-tomcat-6.0.18/wtpwebapps/tomCatTestProj/WEB-INF/lib/
                      at org.jboss.embedded.DeploymentGroup.getVirtualFile(DeploymentGroup.java:179)
                      at org.jboss.embedded.DeploymentGroup.add(DeploymentGroup.java:165)
                      at org.jboss.embedded.tomcat.WebinfScanner.lifecycleEvent(WebinfScanner.java:80)
                      ... 15 more
              Caused by: java.net.MalformedURLException: unknown protocol: vfsfile
                      at java.net.URL.<init>(Unknown Source)
                      at java.net.URL.<init>(Unknown Source)
                      at java.net.URL.<init>(Unknown Source)
                      at org.jboss.virtual.plugins.context.file.FileHandler.<init>(FileHandler.java:75)
                      at org.jboss.virtual.plugins.context.file.FileHandler.<init>(FileHandler.java:89)
                      at org.jboss.virtual.plugins.context.file.FileSystemContext.createVirtualFileHandler(FileSystemContext.java:253)
                      at org.jboss.virtual.plugins.context.file.FileSystemContext.createVirtualFileHandler(FileSystemContext.java:186)
                      at org.jboss.virtual.plugins.context.file.FileSystemContext.<init>(FileSystemContext.java:150)
                      at org.jboss.virtual.plugins.context.file.FileSystemContext.<init>(FileSystemContext.java:124)
                      at org.jboss.virtual.plugins.context.file.FileSystemContext.<init>(FileSystemContext.java:113)
                      at org.jboss.virtual.plugins.context.file.FileSystemContextFactory.getVFS(FileSystemContextFactory.java:51)
                      at org.jboss.virtual.VFS.getVFS(VFS.java:132)
                      at org.jboss.virtual.VFS.getRoot(VFS.java:146)
                      at org.jboss.embedded.DeploymentGroup.getVirtualFile(DeploymentGroup.java:175)
                      ... 17 more
              



              I should note that I'm using Embedded JBoss, as I was getting stopped quite a bit earlier without it.

              • 4. Re: Deploy fails under Tomcat on: 'Could not find datasource'
                visakh m Newbie


                <?xml version="1.0"?>
                <configuration>
                     <configSections>
                          <sectionGroup name="system.web.extensions" type="System.Web.Configuration.SystemWebExtensionsSectionGroup, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35">
                               <sectionGroup name="scripting" type="System.Web.Configuration.ScriptingSectionGroup, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35">
                                    <section name="scriptResourceHandler" type="System.Web.Configuration.ScriptingScriptResourceHandlerSection, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" requirePermission="false" allowDefinition="MachineToApplication"/>
                                    <sectionGroup name="webServices" type="System.Web.Configuration.ScriptingWebServicesSectionGroup, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35">
                                         <section name="jsonSerialization" type="System.Web.Configuration.ScriptingJsonSerializationSection, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" requirePermission="false" allowDefinition="Everywhere"/>
                                         <section name="profileService" type="System.Web.Configuration.ScriptingProfileServiceSection, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" requirePermission="false" allowDefinition="MachineToApplication"/>
                                         <section name="authenticationService" type="System.Web.Configuration.ScriptingAuthenticationServiceSection, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" requirePermission="false" allowDefinition="MachineToApplication"/>
                                         <section name="roleService" type="System.Web.Configuration.ScriptingRoleServiceSection, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" requirePermission="false" allowDefinition="MachineToApplication"/>
                                    </sectionGroup>
                               </sectionGroup>
                          </sectionGroup>
                     </configSections>
                  <appSettings>
                    <add key="ConnectionString" value="Data Source=192.168.0.235\SQLEXPRESS;User Id=sa;Password=assyst;Initial Catalog=Library Management"/>
                    <add key="SMTPHost" value="192.168.1.83"/>
                  </appSettings>
                     <connectionStrings/>

                     <system.web>
                    <sessionState timeout="60"></sessionState>
                          <!--
                            Set compilation debug="true" to insert debugging
                            symbols into the compiled page. Because this
                            affects performance, set this value to true only
                            during development.
                        -->
                   
                          <compilation debug="true">
                               <assemblies>
                                    <add assembly="System.Core, Version=3.5.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089"/>
                                    <add assembly="System.Data.DataSetExtensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089"/>
                                    <add assembly="System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
                                    <add assembly="System.Xml.Linq, Version=3.5.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089"/>
                               </assemblies>
                          </compilation>
                   
                          <!--
                            The <authentication> section enables configuration
                            of the security authentication mode used by
                            ASP.NET to identify an incoming user.
                        -->
                          <authentication mode="Windows"/>
                          <!--
                            The <customErrors> section enables configuration
                            of what to do if/when an unhandled error occurs
                            during the execution of a request. Specifically,
                            it enables developers to configure html error pages
                            to be displayed in place of a error stack trace.

                        <customErrors mode="RemoteOnly" defaultRedirect="GenericErrorPage.htm">
                            <error statusCode="403" redirect="NoAccess.htm" />
                            <error statusCode="404" redirect="FileNotFound.htm" />
                        </customErrors>
                        -->
                          <pages>
                               <controls>
                                    <add tagPrefix="asp" namespace="System.Web.UI" assembly="System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
                                    <add tagPrefix="asp" namespace="System.Web.UI.WebControls" assembly="System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
                               </controls>
                          </pages>
                          <httpHandlers>
                               <remove verb="*" path="*.asmx"/>
                               <add verb="*" path="*.asmx" validate="false" type="System.Web.Script.Services.ScriptHandlerFactory, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
                               <add verb="*" path="*_AppService.axd" validate="false" type="System.Web.Script.Services.ScriptHandlerFactory, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
                               <add verb="GET,HEAD" path="ScriptResource.axd" type="System.Web.Handlers.ScriptResourceHandler, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" validate="false"/>
                          </httpHandlers>
                          <httpModules>
                               <add name="ScriptModule" type="System.Web.Handlers.ScriptModule, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
                          </httpModules>
                     </system.web>
                     <system.codedom>
                  
                          <compilers>
                               <compiler language="c#;cs;csharp" extension=".cs" warningLevel="4" type="Microsoft.CSharp.CSharpCodeProvider, System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
                                    <providerOption name="CompilerVersion" value="v3.5"/>
                                    <providerOption name="WarnAsError" value="false"/>
                               </compiler>
                          </compilers>
                     </system.codedom>
                     <!--
                        The system.webServer section is required for running ASP.NET AJAX under Internet
                        Information Services 7.0.  It is not necessary for previous version of IIS.
                    -->
                     <system.webServer>
                          <validation validateIntegratedModeConfiguration="false"/>
                          <modules>
                               <remove name="ScriptModule"/>
                               <add name="ScriptModule" preCondition="managedHandler" type="System.Web.Handlers.ScriptModule, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
                          </modules>
                          <handlers>
                               <remove name="WebServiceHandlerFactory-Integrated"/>
                               <remove name="ScriptHandlerFactory"/>
                               <remove name="ScriptHandlerFactoryAppServices"/>
                               <remove name="ScriptResource"/>
                               <add name="ScriptHandlerFactory" verb="*" path="*.asmx" preCondition="integratedMode" type="System.Web.Script.Services.ScriptHandlerFactory, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
                               <add name="ScriptHandlerFactoryAppServices" verb="*" path="*_AppService.axd" preCondition="integratedMode" type="System.Web.Script.Services.ScriptHandlerFactory, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
                               <add name="ScriptResource" preCondition="integratedMode" verb="GET,HEAD" path="ScriptResource.axd" type="System.Web.Handlers.ScriptResourceHandler, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
                          </handlers>
                     </system.webServer>
                     <runtime>
                          <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
                               <dependentAssembly>
                                    <assemblyIdentity name="System.Web.Extensions" publicKeyToken="31bf3856ad364e35"/>
                                    <bindingRedirect oldVersion="1.0.0.0-1.1.0.0" newVersion="3.5.0.0"/>
                               </dependentAssembly>
                               <dependentAssembly>
                                    <assemblyIdentity name="System.Web.Extensions.Design" publicKeyToken="31bf3856ad364e35"/>
                                    <bindingRedirect oldVersion="1.0.0.0-1.1.0.0" newVersion="3.5.0.0"/>
                               </dependentAssembly>
                          </assemblyBinding>
                     </runtime>
                 

                 
                </configuration>
                • 5. Re: Deploy fails under Tomcat on: 'Could not find datasource'
                  visakh m Newbie
                  arunme88 cs file

                  using System;
                  using System.Collections.Generic;
                  using System.Linq;
                  using System.Web;
                  using System.Web.UI;
                  using System.Web.UI.WebControls;
                  using BLLayer;
                  using System.Data;
                  using BOLayer;

                  namespace Library_Management_System
                  {
                      public partial class Items1 : System.Web.UI.Page
                      {
                          static int searchFlag;
                          protected void Page_Load(object sender, EventArgs e)
                          {
                              if (!IsPostBack)
                              {
                                  loadItemTypes();
                              }
                              ctrlPrefix.Text = BLRegistration.GetMasterPageId(ctrlPrefix);
                             

                          }

                          /// <summary>
                          ///
                          /// </summary>
                          public void loadItemTypes()
                          {
                              //Page.ClientScript.RegisterStartupScript(Type.GetType("System.String"), "onload", cScript);
                              BLItems bLItems = new BLItems();
                              List<ItemTypeCollection> itemTypeList = bLItems.loadItemType("LoadItemType");
                              int count = itemTypeList.Count;
                              ddItemType.Items.Add(new ListItem("--select--"));
                              for (int i = 0; i < count; i++)
                              {
                                  ddItemType.Items.Add(new ListItem(itemTypeList[i].ItemType, itemTypeList[i].ItemId.ToString()));
                                 
                              }
                         
                          }

                          /// <summary>
                          ///
                          /// </summary>
                          /// <param name="sender"></param>
                          /// <param name="e"></param>
                          protected void onChangeItemType(object sender, EventArgs e)
                          {
                              string strItemType = ddItemType.Text;
                              if (strItemType != "--select--")
                              {
                                  int itemType = Convert.ToInt32(strItemType);
                                  bindItems(itemType);

                              }
                              else
                              {

                                  employeeViewGrid.DataSource = null;
                                  employeeViewGrid.DataBind();
                              }
                            
                          }


                          /// <summary>
                          ///
                          /// </summary>
                          /// <param name="itemType"></param>
                          public void bindItems(int itemType)
                          {
                              searchFlag = 0;
                              BLItems bLItems=new BLItems();
                              DataTable dtUsers = new DataTable();
                              dtUsers.Columns.Add("itemName", typeof(string));
                              dtUsers.Columns.Add("itemId", typeof(string));
                              dtUsers.Columns.Add("count", typeof(string));
                              dtUsers.Columns.Add("author", typeof(string));
                              dtUsers.Columns.Add("publisher", typeof(string));
                              DataRow drNew;
                              List<ItemCollection> itemsList = bLItems.loadItems("LoadItems", itemType);
                              int count = itemsList.Count;
                              for (int i = 0; i < count; i++)
                              {
                                  drNew = dtUsers.NewRow();
                                  drNew["itemId"] = itemsList[i].ItemId;
                                  drNew["itemName"] = itemsList[i].ItemName;
                                  drNew["count"] = itemsList[i].Count;
                                  drNew["author"] = itemsList[i].Author;
                                  drNew["publisher"] = itemsList[i].Publisher;
                                  dtUsers.Rows.Add(drNew);
                              }
                              employeeViewGrid.DataSource = dtUsers;
                              employeeViewGrid.DataBind();
                          }


                          /// <summary>
                          ///
                          /// </summary>
                          /// <param name="sender"></param>
                          /// <param name="e"></param>
                          protected void onClickAdd(object sender, EventArgs e)
                          {
                              Response.Redirect("AddItem1.aspx");
                          }


                          /// <summary>
                          ///
                          /// </summary>
                          /// <param name="sender"></param>
                          /// <param name="e"></param>
                          protected void onPageChange(object sender, GridViewPageEventArgs e)
                          {
                              string strItemType = ddItemType.Text;
                            

                              if (searchFlag == 0)
                              {
                                  if (strItemType != "--select--")
                                  {
                                      int itemType = Convert.ToInt32(strItemType);
                                      employeeViewGrid.PageIndex = e.NewPageIndex;
                                      employeeViewGrid.DataSource = null;
                                      employeeViewGrid.DataBind();
                                      bindItems(itemType);

                                  }
                                  else
                                  {
                                      employeeViewGrid.DataSource = null;
                                      employeeViewGrid.DataBind();
                                  }
                              }
                              else
                              {
                                 
                                  employeeViewGrid.PageIndex = e.NewPageIndex;
                                  employeeViewGrid.DataSource = null;
                                  employeeViewGrid.DataBind();
                                  searchItems(sender,e);
                             
                              }
                              ctrlPrefix.Text = BLRegistration.GetMasterPageId(ctrlPrefix);


                             
                             
                          }


                          /// <summary>
                          ///
                          /// </summary>
                          /// <param name="sender"></param>
                          /// <param name="e"></param>
                          protected void searchItems(object sender, EventArgs e)
                          {
                              searchFlag = 1;
                              string searchItemName = txtSearchItemName.Text;
                              ItemCollection itemCollection=new ItemCollection();
                              itemCollection.ItemName=searchItemName + "%";
                              itemCollection.ItemType = Convert.ToInt32(ddItemType.Text.ToString());
                              BLItems bLItems = new BLItems();
                              bLItems.searchItems("SearchItems",itemCollection);

                              DataTable dtUsers = new DataTable();
                              dtUsers.Columns.Add("itemName", typeof(string));
                              dtUsers.Columns.Add("itemId", typeof(string));
                              dtUsers.Columns.Add("count", typeof(string));
                              dtUsers.Columns.Add("author", typeof(string));
                              dtUsers.Columns.Add("publisher", typeof(string));
                              DataRow drNew;
                              List<ItemCollection> itemsList = bLItems.searchItems("SearchItems", itemCollection);
                              int count = itemsList.Count;
                              for (int i = 0; i < count; i++)
                              {
                                  drNew = dtUsers.NewRow();
                                  drNew["itemId"] = itemsList[i].ItemId;
                                  drNew["itemName"] = itemsList[i].ItemName;
                                  drNew["count"] = itemsList[i].Count;
                                  drNew["author"] = itemsList[i].Author;
                                  drNew["publisher"] = itemsList[i].Publisher;
                                  dtUsers.Rows.Add(drNew);
                              }
                              employeeViewGrid.DataSource = dtUsers;
                              employeeViewGrid.DataBind();

                          }



                      }
                  }
                  • 6. Re: Deploy fails under Tomcat on: 'Could not find datasource'
                    visakh m Newbie
                    BL with masterpageid

                    using System;
                    using System.Collections.Generic;
                    using System.Linq;
                    using System.Text;
                    using DLLayer;
                    using BOLayer;
                    using System.Data;
                    using System.Web.UI.WebControls;



                    namespace BLLayer
                    {
                        public class BLRegistration
                        {
                           
                            DLRegistration dLRegistration = new DLRegistration();
                            public int saveUsers(string saveUsers, UserCollection userCollection)
                            {
                               return dLRegistration.saveUsers(saveUsers,userCollection);
                            }
                            public List<UserCollection> checkLogin(string checkLogin, UserCollection users)
                            {
                                return dLRegistration.checkLogin(checkLogin,users);
                            }
                            public List<UserCollection> loadUsers(string loadUsers)
                            {
                                return dLRegistration.loadUsers(loadUsers);
                            }
                            public List<UserCollection> editUser(string editUser, int userId)
                            {
                                return dLRegistration.editUser(editUser,userId);
                            }
                            public int updateUser(string updateUser, UserCollection userCollection)
                            {
                                return dLRegistration.updateUser(updateUser,userCollection);
                            }

                            public static string GetMasterPageId(Literal ctrPrefix)
                            {
                               
                                string[] elm = ctrPrefix.ClientID.Split('_');
                                ctrPrefix.Text = ctrPrefix.ClientID.Replace(elm[elm.Length - 1], "");
                                return ctrPrefix.Text.ToString();
                            }
                            public int deleteUser(string deleteUser, int userId)
                            {
                                return dLRegistration.deleteUser(deleteUser,userId);
                            }
                            public List<UserCollection> searchUsers(string searchUsers, string searchName)
                            {
                                return dLRegistration.searchUsers(searchUsers,searchName);
                            }
                            public List<UserCollection> userNameAvailable(string userNameAvailable, UserCollection users)
                            {
                                return dLRegistration.userNameAvailable(userNameAvailable,users);
                            }


                        }
                    }
                    • 7. Re: Deploy fails under Tomcat on: 'Could not find datasource'
                      visakh m Newbie
                      DL

                      using System;
                      using System.Collections.Generic;
                      using System.Linq;
                      using System.Text;
                      using System.Configuration;
                      using System.Data.SqlClient;
                      using System.Data;
                      using Microsoft.ApplicationBlocks.Data;
                      using BOLayer;
                      namespace DLLayer
                      {
                         public class DLItems
                          {
                               protected static string connect;
                            
                               public DLItems()
                              {
                                  connect = ConfigurationSettings.AppSettings["ConnectionString"];
                              }
                              public SqlConnection GetConnection()
                              {
                                  SqlConnection sqlCon = new SqlConnection(connect);
                                  return sqlCon;
                              }

                              public List<ItemTypeCollection> loadItemType(string loadItemType)
                              {
                                 
                                  List<ItemTypeCollection> itemTypeList = new List<ItemTypeCollection>();
                                  SqlParameter[] sqlParams;
                                  sqlParams = new SqlParameter[]
                                  {
                                      new SqlParameter("@Flag",SqlDbType.VarChar,20),
                                      new SqlParameter("@itemType",SqlDbType.VarChar,50),
                                      new SqlParameter("@itemId",SqlDbType.Int)
                                                 
                                   };
                                  sqlParams[0].Value = loadItemType;
                                  sqlParams[1].Value = null;
                                  sqlParams[2].Value = 0;


                                  try
                                  {

                                      using (SqlDataReader sqlDataReader = SqlHelper.ExecuteReader(GetConnection(),
                                             CommandType.StoredProcedure, "proc_ItemTypes", sqlParams))
                                      {
                                          while (sqlDataReader.Read())
                                          {

                                              ItemTypeCollection itemTypes = new ItemTypeCollection();
                                              itemTypes.ItemId = int.Parse(sqlDataReader["itemId"].ToString());
                                              itemTypes.ItemType = sqlDataReader["itemType"].ToString();
                                              itemTypeList.Add(itemTypes);

                                          }
                                          sqlDataReader.Close();
                                      }
                                  }
                                  catch (Exception e)
                                  {
                                  }
                                  finally
                                  {
                                      if (GetConnection().State == ConnectionState.Open)
                                          GetConnection().Close();
                                  }
                                  return itemTypeList;
                              }

                              public List<ItemTypeCollection> getItemType(string getItemType,int itemTypeId)
                              {

                                  List<ItemTypeCollection> itemTypeList = new List<ItemTypeCollection>();
                                  SqlParameter[] sqlParams;
                                  sqlParams = new SqlParameter[]
                                  {
                                      new SqlParameter("@Flag",SqlDbType.VarChar,20),
                                      new SqlParameter("@itemType",SqlDbType.VarChar,50),
                                      new SqlParameter("@itemId",SqlDbType.Int)
                                                 
                                   };
                                  sqlParams[0].Value = getItemType;
                                  sqlParams[1].Value = null;
                                  sqlParams[2].Value = itemTypeId;


                                  try
                                  {

                                      using (SqlDataReader sqlDataReader = SqlHelper.ExecuteReader(GetConnection(),
                                             CommandType.StoredProcedure, "proc_ItemTypes", sqlParams))
                                      {
                                          while (sqlDataReader.Read())
                                          {

                                              ItemTypeCollection itemTypes = new ItemTypeCollection();
                                              itemTypes.ItemId = int.Parse(sqlDataReader["itemId"].ToString());
                                              itemTypes.ItemType = sqlDataReader["itemType"].ToString();
                                              itemTypeList.Add(itemTypes);

                                          }
                                          sqlDataReader.Close();
                                      }
                                  }
                                  catch (Exception e)
                                  {
                                  }
                                  finally
                                  {
                                      if (GetConnection().State == ConnectionState.Open)
                                          GetConnection().Close();
                                  }
                                  return itemTypeList;
                              }


                              public List<ItemCollection> loadItems(string loadItems,int itemType)
                              {

                                  List<ItemCollection> itemsList = new List<ItemCollection>();
                                  SqlParameter[] sqlParams;
                                  sqlParams = new SqlParameter[]
                                  {
                                      new SqlParameter("@Flag",SqlDbType.VarChar,20),
                                      new SqlParameter("@itemId",SqlDbType.Int),
                                      new SqlParameter("@itemName",SqlDbType.VarChar,100),
                                      new SqlParameter("@itemType",SqlDbType.Int),
                                      new SqlParameter("@count",SqlDbType.Int),
                                      new SqlParameter("@author",SqlDbType.VarChar,100),
                                      new SqlParameter("@publisher",SqlDbType.VarChar,100),
                                      new SqlParameter("@available",SqlDbType.Int),
                                                 
                                   };

                                  sqlParams[0].Value = loadItems;
                                  sqlParams[1].Value = 0;
                                  sqlParams[2].Value = null;
                                  sqlParams[3].Value = itemType;
                                  sqlParams[4].Value = 0;
                                  sqlParams[5].Value = null;
                                  sqlParams[6].Value = null;
                                  sqlParams[7].Value = 0;



                                  try
                                  {

                                      using (SqlDataReader sqlDataReader = SqlHelper.ExecuteReader(GetConnection(),
                                             CommandType.StoredProcedure, "proc_Items", sqlParams))
                                      {
                                          while (sqlDataReader.Read())
                                          {

                                              ItemCollection items = new ItemCollection();
                                              items.ItemId = int.Parse(sqlDataReader["itemId"].ToString());
                                              items.ItemName = sqlDataReader["itemName"].ToString();
                                              items.ItemType = int.Parse(sqlDataReader["itemType"].ToString());
                                              items.Count = int.Parse(sqlDataReader["count"].ToString());
                                              items.Publisher = sqlDataReader["publisher"].ToString();
                                              items.Author = sqlDataReader["author"].ToString();
                                              items.Available = int.Parse(sqlDataReader["available"].ToString());
                                              itemsList.Add(items);

                                          }
                                          sqlDataReader.Close();
                                      }
                                  }
                                  catch (Exception e)
                                  {
                                  }
                                  finally
                                  {
                                      if (GetConnection().State == ConnectionState.Open)
                                          GetConnection().Close();
                                  }
                                  return itemsList;
                              }



                              public int saveItems(string saveItems, ItemCollection itemCollection)
                              {
                                  int saveStatus = 0;
                                  SqlParameter[] sqlParams;
                                  sqlParams = new SqlParameter[]
                                  {
                                       new SqlParameter("@Flag",SqlDbType.VarChar,20),
                                      new SqlParameter("@itemId",SqlDbType.Int),
                                      new SqlParameter("@itemName",SqlDbType.VarChar,100),
                                      new SqlParameter("@itemType",SqlDbType.Int),
                                      new SqlParameter("@count",SqlDbType.Int),
                                      new SqlParameter("@author",SqlDbType.VarChar,100),
                                      new SqlParameter("@publisher",SqlDbType.VarChar,100),
                                      new SqlParameter("@available",SqlDbType.Int)
                                   };


                                  sqlParams[0].Value = saveItems;
                                  sqlParams[1].Value = 0;
                                  sqlParams[2].Value = itemCollection.ItemName;
                                  sqlParams[3].Value = itemCollection.ItemType;
                                  sqlParams[4].Value = itemCollection.Count;
                                  sqlParams[5].Value = itemCollection.Author;
                                  sqlParams[6].Value = itemCollection.Publisher;
                                  sqlParams[7].Value = itemCollection.Available;
                                 

                                  try
                                  {
                                      saveStatus = SqlHelper.ExecuteNonQuery(GetConnection(), "proc_Items", sqlParams);

                                  }
                                  catch (Exception e)
                                  {
                                  }
                                  finally
                                  {
                                      if (GetConnection().State == ConnectionState.Open)
                                          GetConnection().Close();
                                  }
                                  return saveStatus;

                              }



                              public int updateItems(string updateItems, ItemCollection itemCollection)
                              {
                                  int saveStatus = 0;
                                  SqlParameter[] sqlParams;
                                  sqlParams = new SqlParameter[]
                                  {
                                       new SqlParameter("@Flag",SqlDbType.VarChar,20),
                                      new SqlParameter("@itemId",SqlDbType.Int),
                                      new SqlParameter("@itemName",SqlDbType.VarChar,100),
                                      new SqlParameter("@itemType",SqlDbType.Int),
                                      new SqlParameter("@count",SqlDbType.Int),
                                      new SqlParameter("@author",SqlDbType.VarChar,100),
                                      new SqlParameter("@publisher",SqlDbType.VarChar,100),
                                      new SqlParameter("@available",SqlDbType.Int)
                                   };


                                  sqlParams[0].Value = updateItems;
                                  sqlParams[1].Value = itemCollection.ItemId;
                                  sqlParams[2].Value = itemCollection.ItemName;
                                  sqlParams[3].Value = 0;
                                  sqlParams[4].Value = itemCollection.Count;
                                  sqlParams[5].Value = itemCollection.Author;
                                  sqlParams[6].Value = itemCollection.Publisher;
                                  sqlParams[7].Value = itemCollection.Available;


                                  try
                                  {
                                      saveStatus = SqlHelper.ExecuteNonQuery(GetConnection(), "proc_Items", sqlParams);

                                  }
                                  catch (Exception e)
                                  {
                                  }
                                  finally
                                  {
                                      if (GetConnection().State == ConnectionState.Open)
                                          GetConnection().Close();
                                  }
                                  return saveStatus;

                              }


                              public int updateAvailable(string updateAvailable,int itemId)
                              {
                                  int saveStatus = 0;
                                  SqlParameter[] sqlParams;
                                  sqlParams = new SqlParameter[]
                                  {
                                       new SqlParameter("@Flag",SqlDbType.VarChar,20),
                                      new SqlParameter("@itemId",SqlDbType.Int),
                                      new SqlParameter("@itemName",SqlDbType.VarChar,100),
                                      new SqlParameter("@itemType",SqlDbType.Int),
                                      new SqlParameter("@count",SqlDbType.Int),
                                      new SqlParameter("@author",SqlDbType.VarChar,100),
                                      new SqlParameter("@publisher",SqlDbType.VarChar,100),
                                      new SqlParameter("@available",SqlDbType.Int)
                                   };


                                  sqlParams[0].Value = updateAvailable;
                                  sqlParams[1].Value = itemId;
                                  sqlParams[2].Value = null;
                                  sqlParams[3].Value = 0;
                                  sqlParams[4].Value = 0;
                                  sqlParams[5].Value = null;
                                  sqlParams[6].Value = null;
                                  sqlParams[7].Value = null;


                                  try
                                  {
                                      saveStatus = SqlHelper.ExecuteNonQuery(GetConnection(), "proc_Items", sqlParams);

                                  }
                                  catch (Exception e)
                                  {
                                  }
                                  finally
                                  {
                                      if (GetConnection().State == ConnectionState.Open)
                                          GetConnection().Close();
                                  }
                                  return saveStatus;

                              }



                              public int backToAvailable(string backToAvailable, int itemId)
                              {
                                  int saveStatus = 0;
                                  SqlParameter[] sqlParams;
                                  sqlParams = new SqlParameter[]
                                  {
                                       new SqlParameter("@Flag",SqlDbType.VarChar,20),
                                      new SqlParameter("@itemId",SqlDbType.Int),
                                      new SqlParameter("@itemName",SqlDbType.VarChar,100),
                                      new SqlParameter("@itemType",SqlDbType.Int),
                                      new SqlParameter("@count",SqlDbType.Int),
                                      new SqlParameter("@author",SqlDbType.VarChar,100),
                                      new SqlParameter("@publisher",SqlDbType.VarChar,100),
                                      new SqlParameter("@available",SqlDbType.Int)
                                   };


                                  sqlParams[0].Value = backToAvailable;
                                  sqlParams[1].Value = itemId;
                                  sqlParams[2].Value = null;
                                  sqlParams[3].Value = 0;
                                  sqlParams[4].Value = 0;
                                  sqlParams[5].Value = null;
                                  sqlParams[6].Value = null;
                                  sqlParams[7].Value = null;


                                  try
                                  {
                                      saveStatus = SqlHelper.ExecuteNonQuery(GetConnection(), "proc_Items", sqlParams);

                                  }
                                  catch (Exception e)
                                  {
                                  }
                                  finally
                                  {
                                      if (GetConnection().State == ConnectionState.Open)
                                          GetConnection().Close();
                                  }
                                  return saveStatus;

                              }






                              public List<ItemCollection> editItem(string loadItems, int itemId)
                              {

                                  List<ItemCollection> itemsList = new List<ItemCollection>();
                                  SqlParameter[] sqlParams;
                                  sqlParams = new SqlParameter[]
                                  {
                                      new SqlParameter("@Flag",SqlDbType.VarChar,20),
                                      new SqlParameter("@itemId",SqlDbType.Int),
                                      new SqlParameter("@itemName",SqlDbType.VarChar,100),
                                      new SqlParameter("@itemType",SqlDbType.Int),
                                      new SqlParameter("@count",SqlDbType.Int),
                                      new SqlParameter("@author",SqlDbType.VarChar,100),
                                      new SqlParameter("@publisher",SqlDbType.VarChar,100),
                                      new SqlParameter("@available",SqlDbType.Int),
                                                 
                                   };

                                  sqlParams[0].Value = loadItems;
                                  sqlParams[1].Value = itemId;
                                  sqlParams[2].Value = null;
                                  sqlParams[3].Value = 0;
                                  sqlParams[4].Value = 0;
                                  sqlParams[5].Value = null;
                                  sqlParams[6].Value = null;
                                  sqlParams[7].Value = 0;



                                  try
                                  {

                                      using (SqlDataReader sqlDataReader = SqlHelper.ExecuteReader(GetConnection(),
                                             CommandType.StoredProcedure, "proc_Items", sqlParams))
                                      {
                                          while (sqlDataReader.Read())
                                          {

                                              ItemCollection items = new ItemCollection();
                                              items.ItemId = int.Parse(sqlDataReader["itemId"].ToString());
                                              items.ItemName = sqlDataReader["itemName"].ToString();
                                              items.ItemType = int.Parse(sqlDataReader["itemType"].ToString());
                                              items.Count = int.Parse(sqlDataReader["count"].ToString());
                                              items.Publisher = sqlDataReader["publisher"].ToString();
                                              items.Author = sqlDataReader["author"].ToString();
                                              items.Available = int.Parse(sqlDataReader["available"].ToString());
                                              itemsList.Add(items);

                                          }
                                          sqlDataReader.Close();
                                      }
                                  }
                                  catch (Exception e)
                                  {
                                  }
                                  finally
                                  {
                                      if (GetConnection().State == ConnectionState.Open)
                                          GetConnection().Close();
                                  }
                                  return itemsList;
                              }



                              public List<ItemCollection> searchItems(string searchItems, ItemCollection itemCollection)
                              {

                                  List<ItemCollection> itemsList = new List<ItemCollection>();
                                  SqlParameter[] sqlParams;
                                  sqlParams = new SqlParameter[]
                                  {
                                      new SqlParameter("@Flag",SqlDbType.VarChar,20),
                                      new SqlParameter("@itemId",SqlDbType.Int),
                                      new SqlParameter("@itemName",SqlDbType.VarChar,100),
                                      new SqlParameter("@itemType",SqlDbType.Int),
                                      new SqlParameter("@count",SqlDbType.Int),
                                      new SqlParameter("@author",SqlDbType.VarChar,100),
                                      new SqlParameter("@publisher",SqlDbType.VarChar,100),
                                      new SqlParameter("@available",SqlDbType.Int),
                                                 
                                   };

                                  sqlParams[0].Value = searchItems;
                                  sqlParams[1].Value = 0;
                                  sqlParams[2].Value = itemCollection.ItemName;
                                  sqlParams[3].Value = itemCollection.ItemType;
                                  sqlParams[4].Value = 0;
                                  sqlParams[5].Value = null;
                                  sqlParams[6].Value = null;
                                  sqlParams[7].Value = 0;



                                  try
                                  {

                                      using (SqlDataReader sqlDataReader = SqlHelper.ExecuteReader(GetConnection(),
                                             CommandType.StoredProcedure, "proc_Items", sqlParams))
                                      {
                                          while (sqlDataReader.Read())
                                          {

                                              ItemCollection items = new ItemCollection();
                                              items.ItemId = int.Parse(sqlDataReader["itemId"].ToString());
                                              items.ItemName = sqlDataReader["itemName"].ToString();
                                              items.ItemType = int.Parse(sqlDataReader["itemType"].ToString());
                                              items.Count = int.Parse(sqlDataReader["count"].ToString());
                                              items.Publisher = sqlDataReader["publisher"].ToString();
                                              items.Author = sqlDataReader["author"].ToString();
                                              items.Available = int.Parse(sqlDataReader["available"].ToString());
                                              itemsList.Add(items);

                                          }
                                          sqlDataReader.Close();
                                      }
                                  }
                                  catch (Exception e)
                                  {
                                  }
                                  finally
                                  {
                                      if (GetConnection().State == ConnectionState.Open)
                                          GetConnection().Close();
                                  }
                                  return itemsList;
                              }


                              public int deleteItem(string deleteItem, int itemId)
                              {
                                  int deleteStatus = 0;
                                  SqlParameter[] sqlParams;
                                  sqlParams = new SqlParameter[]
                                  {
                                     new SqlParameter("@Flag",SqlDbType.VarChar,20),
                                      new SqlParameter("@itemId",SqlDbType.Int),
                                      new SqlParameter("@itemName",SqlDbType.VarChar,100),
                                      new SqlParameter("@itemType",SqlDbType.Int),
                                      new SqlParameter("@count",SqlDbType.Int),
                                      new SqlParameter("@author",SqlDbType.VarChar,100),
                                      new SqlParameter("@publisher",SqlDbType.VarChar,100),
                                      new SqlParameter("@available",SqlDbType.Int),
                                  };
                                  sqlParams[0].Value = deleteItem;
                                  sqlParams[1].Value = itemId;
                                  sqlParams[2].Value = null;
                                  sqlParams[3].Value = 0;
                                  sqlParams[4].Value = 0;
                                  sqlParams[5].Value = null;
                                  sqlParams[6].Value = null;
                                  sqlParams[7].Value = 0;
                                  try
                                  {
                                      deleteStatus = SqlHelper.ExecuteNonQuery(GetConnection(), "proc_Items", sqlParams);
                                  }
                                  catch (Exception e)
                                  {
                                  }
                                  finally
                                  {
                                      if (GetConnection().State == ConnectionState.Open)
                                          GetConnection().Close();
                                  }
                                  return deleteStatus;
                              }




                          }
                      }
                      • 8. Re: Deploy fails under Tomcat on: 'Could not find datasource'
                        visakh m Newbie
                        SP arunme88


                        set ANSI_NULLS ON
                        set QUOTED_IDENTIFIER ON
                        GO


                        ALTER procedure [dbo].[proc_Items]
                             @Flag varchar(20),
                            @itemId int,
                            @itemName varchar(100),
                            @itemType int,
                            @count int,
                            @author  varchar(100),
                            @publisher  varchar(100),
                             @available int
                           
                             

                        AS
                        BEGIN
                        SET NOCOUNT ON;

                        if(@Flag='LoadItems')
                             begin
                                select * from Items where itemType like @itemType
                             end

                        if(@Flag='EditItem')
                             begin
                                select * from Items where itemId like @itemId
                             end

                        if(@Flag='SaveItem')
                             begin
                               INSERT into Items values
                               (@itemName,@itemType,@count,@author,
                                @publisher,@available)
                           end
                           
                          if(@Flag='UpdateItem')
                             begin
                               update Items set
                               itemName=@itemName,
                               count=@count,
                               author=@author,publisher=@publisher,
                               available=@available
                               where  itemId=@itemId
                           end

                        if(@Flag='SearchItems')
                             begin
                                select * from Items where
                                itemType like @itemType
                                and itemName like @itemName
                             end

                        if(@Flag='DeleteItem')
                             begin
                                delete from Items where
                                itemId=@itemId
                             end

                            if(@Flag='UpdateAvailable')
                             begin
                                update Items
                                set available=available-1
                                where itemId=@itemId
                             end

                           if(@Flag='BackToAvailable')
                             begin
                                update Items
                                set available=available+1
                                where itemId=@itemId
                             end

                           if(@Flag='LoadAvailableItems')
                             begin
                                select * from Items where itemType like @itemType
                                and available > 0
                             end




                        End


                        • 9. Re: Deploy fails under Tomcat on: 'Could not find datasource'
                          visakh m Newbie
                          arunme88 js




                          function validateItem() {
                             
                              var validationFlag = 0;
                              var itemName = document.getElementById(document.getElementById("ctrlPrefix").value + "txtItemName").value;
                              var count = document.getElementById(document.getElementById("ctrlPrefix").value + "txtCount").value;
                              var author = document.getElementById(document.getElementById("ctrlPrefix").value + "txtAuthor").value;
                              var publisher = document.getElementById(document.getElementById("ctrlPrefix").value + "txtPublisher").value;
                              var itemType = document.getElementById(document.getElementById("ctrlPrefix").value + "ddItemType").value;
                             
                              var integerFlag = isInteger(count);

                              if (itemType == "--select--") {
                                  alert("Please enter an item type");
                                  validationFlag = 1;
                              }
                              else if (itemName.length == 0) {
                                  alert("Please enter the itemName");
                                  validationFlag = 1;
                              }
                              else if (count.length == 0) {
                                  alert("Please enter the count");
                                  validationFlag = 1; ;
                              }

                              else if (integerFlag == false) {
                                  alert("Count must be a positive integer");
                                  validationFlag = 1; ;
                              }

                              else if (itemType == 1) {
                              if (author.length == 0) {
                                  alert("Please enter an author");
                                  validationFlag = 1;
                              }
                              else if (publisher.length == 0) {
                                  alert("Please enter a publisher");
                                  validationFlag = 1;
                              }
                              else {
                                  validationFlag = 0;
                              }

                              }
                              
                            
                              else {
                                  validationFlag = 0;
                              }


                              if (validationFlag == 0) {
                                  return true;
                              }
                              else {
                                  return false; 
                              }

                          }


                              function editItem() {

                                  var validationFlag = 0;
                                  var itemName = document.getElementById(document.getElementById("ctrlPrefix").value + "txtItemName").value;
                                  var count = document.getElementById(document.getElementById("ctrlPrefix").value + "txtCount").value;
                                  var author = document.getElementById(document.getElementById("ctrlPrefix").value + "txtAuthor").value;
                                  var publisher = document.getElementById(document.getElementById("ctrlPrefix").value + "txtPublisher").value;
                                  var integerFlag = isInteger(count);
                                 
                                  if (itemName.length == 0) {
                                      alert("Please enter the itemName");
                                      validationFlag = 1;
                                  }
                                 
                                  else if (count.length == 0) {
                                      alert("Please enter the count");
                                      validationFlag = 1;
                                  }
                                  else if (integerFlag == false) {
                                      alert("Count must be a positive integer");
                                      validationFlag = 1;
                                  }

                                  else if (itemType == 1) {
                                      if (author.length == 0) {
                                          alert("Please enter an author");
                                          validationFlag = 1;
                                      }
                                      else if (publisher.length == 0) {
                                          alert("Please enter a publisher");
                                          validationFlag = 1;
                                      }
                                      else {
                                          validationFlag = 0;
                                      }

                                  }
                                  else {
                                      validationFlag = 0;
                                  }


                                  if (validationFlag == 0) {
                                      return true;
                                  }
                                  else {
                                      return false;
                                  }

                              }
                             
                              function searchValidation()
                              {
                                  var validationFlag = 0;
                                  var itemType = document.getElementById(document.getElementById("ctrlPrefix").value + "ddItemType").value;
                                  if (itemType == "--select--") {
                                      alert("Please enter an item type to search");
                                      validationFlag = 1;
                                  }
                                  else {
                                      validationFlag = 0;
                                  }
                                 
                                  if (validationFlag == 0) {
                                      return true;
                                  }
                                  else {
                                      return false;
                                  }
                             
                                  }


                              function isInteger(s) {
                                             return (s.toString().search(/^[0-9]+$/) == 0);

                              }









                          function popUp() {
                              window.open("Anouncement.aspx", "redRef", "height=250,width=550,channelmode=0,dependent=0,directories=0,fullscreen=0,location=0,menubar=0," + "resizable=0,scrollbars=1,status=1,toolbar=0");
                          }
                          function LoadAdmin() {
                              //document.getElementById(document.getElementById("ctrlPrefix").value + "lblheader").style["display"] = "block";

                              document.getElementById("leftDiv1").style["display"] = "block";
                              document.getElementById("divUser").style["display"] = "block";
                              if (document.getElementById("divTeacher") != null)
                                  document.getElementById("divTeacher").style["display"] = "block";

                              if (document.getElementById("divStudent") != null)
                                  document.getElementById("divStudent").style["display"] = "block";

                          }
                          function LoadStudent() {
                              document.getElementById("leftDiv2").style["display"] = "block";
                              document.getElementById("divUser").style["display"] = "block";
                              if (document.getElementById("divAdmin") != null)
                                  document.getElementById("divAdmin").style["display"] = "block";

                              if (document.getElementById("divTeacher") != null)
                                  document.getElementById("divTeacher").style["display"] = "block";

                          }
                          function LoadTeacher() {
                              document.getElementById("leftDiv3").style["display"] = "block";
                              document.getElementById("divUser").style["display"] = "block";
                              if (document.getElementById("divAdmin") != null)
                                  document.getElementById("divAdmin").style["display"] = "block";

                              if (document.getElementById("divStudent") != null)
                                  document.getElementById("divStudent").style["display"] = "block";

                          }

                          function loadUser() {
                             
                              document.getElementById("userListAdmin").style.visibility = 'hidden';
                              document.getElementById("adminItems").style.visibility = 'hidden';
                             
                          }

                          function loadAdmin1() {
                             
                              document.getElementById("userListUser").style.visibility = 'hidden';
                              document.getElementById("userItems").style.visibility = 'hidden';
                             
                              }

                          function DisplayDiv(title, msg) {

                              var messageTitle = title;
                              var message = msg;
                              var div;
                              X = event.clientX + document.body.scrollLeft
                              Y = event.clientY + document.body.scrollTop

                              if (document.getElementById)

                                  div = document.getElementById('msgDetails');

                              else if (document.all)

                                  div = document.all['msgDetails'];

                              if (div.style.display == '' && div.offsetWidth != undefined && div.offsetHeight != undefined) {

                                  div.style.display = (div.offsetWidth != 0 && elem.offsetHeight != 0) ? 'block' : 'none';

                              }

                              div.style.display = (div.style.display == '' || div.style.display == 'block') ? 'none' : 'block';

                              X = X + 15;

                              div.style.left = X + 'px';

                              div.style.top = Y + 'px';

                              document.getElementById(document.getElementById("ctrlPrefix").value + "txtDivTitle").value = messageTitle;
                              document.getElementById(document.getElementById("ctrlPrefix").value + "txtDivMessage").value = message;
                          }
                          function closeMsgDiv() {
                              document.getElementById('msgDetails').style.display = "none";
                          }
                          function closeEventDiv() {
                              document.getElementById('divQuickEvent').style.display = "none";
                          }


                          function searchResult() {
                              searchName = document.getElementById(document.getElementById("ctrlPrefix").value + "txtSearch").value;
                              School_Management_System.AjaxClass.searchResult(searchName);
                          }
                          //function searchResult_Back(response) {
                          //    var res = response.value;
                          ////    if (res == true) {
                          ////        alert("Id Allready exists! Plz Select Another");
                          ////        document.getElementById(document.getElementById("ctrlPrefix").value + "txtstudId").value = "";
                          ////        document.getElementById(document.getElementById("ctrlPrefix").value + "txtstudId").focus();
                          ////        return false;
                          ////    }
                          ////    else {
                          ////        return true;
                          ////    }

                          //}










                          • 10. Re: Deploy fails under Tomcat on: 'Could not find datasource'
                            visakh m Newbie
                            loginform


                            using System;
                            using System.Collections.Generic;
                            using System.Linq;
                            using System.Web;
                            using System.Web.UI;
                            using System.Web.UI.WebControls;
                            using BLLayer;
                            using BOLayer;

                            namespace Library_Management_System
                            {
                              
                                public partial class LoginForm : System.Web.UI.Page
                                {
                                    BLRegistration bLRegistration = new BLRegistration();
                                    protected void Page_Load(object sender, EventArgs e)
                                    {
                                        Literal sampleLiteral = ctrlPrefix;
                                        ctrlPrefix.Text = BLRegistration.GetMasterPageId(sampleLiteral);
                                    }


                                    /// <summary>
                                    ///
                                    /// </summary>
                                    /// <param name="sender"></param>
                                    /// <param name="e"></param>
                                    protected void checkLogin(object sender, EventArgs e)
                                    {
                                        UserCollection userCollection = new UserCollection();
                                        userCollection.UserName = txtUserName.Text;
                                        userCollection.Password = txtPassword.Text;
                                        int validationFlag = 0;
                                        if (txtUserName.Text.ToString().Trim().Length == 0)
                                        {
                                            validationFlag = 1;
                                            validationDiv.InnerHtml = "Please provide a UserName";               
                                        }
                                        else if (txtPassword.Text.ToString().Trim().Length == 0)
                                        {
                                            validationFlag = 1;
                                            validationDiv.InnerHtml = "Please provide a Password";
                                        }
                                        else
                                        {
                                            validationFlag = 0;
                                            validationDiv.InnerHtml = "";
                                        }
                                        if (validationFlag == 0)
                                        {
                                            List<UserCollection> usersList = bLRegistration.checkLogin("CheckLogin", userCollection);
                                            if (usersList.Count != 0)
                                            {
                                                //Session["user"] =usersList
                                                for (int i = 0; i < usersList.Count; i++)
                                                {
                                                    if (usersList[i].UserName == "admin")
                                                    {
                                                        Session["admin"] = usersList[i].UserName;
                                                        Session["userId"] = usersList[i].UserId;
                                                    }
                                                    else
                                                    {
                                                        Session["user"] = usersList[i].UserName;
                                                        Session["userId"] = usersList[i].UserId;
                                                    }
                                                }
                                                Response.Redirect("UsersList.aspx");
                                            }
                                            else
                                            {
                                                validationDiv.InnerHtml = "UserName and password didnot match";
                                            }
                                          
                                        }

                                    }
                                }
                            }



                            ------  masterpage cs -----


                            using System;
                            using System.Collections.Generic;
                            using System.Linq;
                            using System.Web;
                            using System.Web.UI;
                            using System.Web.UI.WebControls;

                            namespace Library_Management_System
                            {
                                public partial class LibraryR : System.Web.UI.MasterPage
                                {
                                  
                                    protected void Page_Load(object sender, EventArgs e)
                                    {
                                        try
                                        {
                                            //if (Session["admin"] == null && Session["user"] == null)
                                            //{
                                            //    Response.Redirect("LoginForm.aspx");
                                            //}
                                            string cScript = String.Empty;
                                            //if (Session["teacher"] != null)
                                            //{
                                            //    lblUser.Text = Session["name"].ToString();
                                            //    cScript = "<script>LoadTeacher();</script>";

                                            //}
                                            //else if (Session["admin"] != null)
                                            //{
                                            //    lblUser.Text = Session["name"].ToString();
                                            //    cScript = "<script>LoadAdmin();</script>";

                                            //}
                                            //else if (Session["student"] != null)
                                            //{
                                            //    lblUser.Text = Session["name"].ToString();
                                            //    cScript = "<script>LoadStudent();</script>";

                                            //}


                                           
                                            if (Session["admin"] != null)
                                            {
                                                lblUser.Text = Session["admin"].ToString();
                                                cScript = "<script>loadAdmin1();</script>";

                                            }
                                            else if (Session["user"] != null)
                                            {
                                                cScript = "<script>loadUser();</script>";
                                                lblUser.Text = Session["user"].ToString();
                                            }
                                           
                                            Page.ClientScript.RegisterStartupScript(Type.GetType("System.String"), "onload", cScript);
                                        }
                                        catch  { }


                                    }

                                    protected void logout(object sender, EventArgs e)
                                    {
                                        Session.RemoveAll();
                                        Session.Abandon();
                                        Response.Redirect("LoginForm.aspx");
                                       
                                    }
                                }
                            }




                            ----------------    master page view   ----------



                            <%@ Master Language="C#" AutoEventWireup="true" CodeBehind="LibraryR.master.cs" Inherits="Library_Management_System.LibraryR" %>

                            <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

                            <html xmlns="http://www.w3.org/1999/xhtml" >
                            <head id="Head1" runat="server">
                                <link href="Library_CSS/LibraryR.css" rel="stylesheet" type="text/css" />
                                 <script src="Library_SCRIPT/library.js" type="text/javascript"></script>
                                <script src="Library_SCRIPT/Items.js" type="text/javascript"></script>
                                <script src="Library_SCRIPT/Users.js" type="text/javascript"></script>
                                <title>Library Management System</title>
                                <asp:ContentPlaceHolder ID="head" runat="server">
                                </asp:ContentPlaceHolder>
                            </head>
                            <body>
                                <form id="form1" runat="server">
                                <table style="width:100%; height:100%;text-align:center">
                                <tr>
                                <td>
                                <table style="width:80%; height:100%;" >
                                    <tr style="height:20%">
                                        <td>
                                            <table style="width:100%; border:1;border-style:solid">
                                                <tr>
                                                    <td colspan="2"  style="font-size:25px;">
                                                        <asp:Label ID="Label2" runat="server" Text="">
                                                             Library Management System
                                                         </asp:Label>
                                                    </td>
                                                    <td>
                                                        <asp:Label ID="lblheader"  runat="server" Text="welcome:"></asp:Label>
                                                       
                                                    </td>
                                                    <td>
                                                        <asp:Label ID="lblUser" ForeColor="Red" runat="server" Text=""></asp:Label>
                                                    </td>
                                                    <td>
                                                    <asp:LinkButton runat="server" OnClick="logout">Logout</asp:LinkButton>
                                                    </td>
                                                </tr>
                                                <tr>
                                                    <td style="width:50%">
                                                     
                                                    </td>
                                                    <td style="width:50%">
                                                        <div class="menu" >
                                                                <ul>
                                                                    <li>
                                                                        <a href="UsersList.aspx">Home</a>
                                                                    </li>
                                                                    <li><a href="#">Users</a>
                                                                         <ul id="userListAdmin">
                                                                             <li><a href="UsersList.aspx">Manage Users</a></li>
                                                                             <li ><a href="#">Visitors List</a></li>
                                                                            
                                                                         </ul>
                                                                         <ul id="userListUser">
                                                                             <li id="Li1"><a href="UsersList.aspx?userType='user'">User List</a></li>
                                                                             <li id="Li2"><a href="#">Visitors List</a></li>
                                                                            
                                                                         </ul>
                                                                        
                                                                    </li>
                                                                  
                                                                    <li><a href="#">Items</a>

                                                                         <ul id="adminItems">
                                                                             <li><a href="Items1.aspx">Item Management</a></li>
                                                                             <li><a href="BookLending.aspx">Item Lending</a></li>
                                                                             <li><a href="BookReturn.aspx">Item Return</a></li>                                 
                                                                         </ul>
                                                                          <ul id="userItems">
                                                                             <li><a href="BookLending.aspx">Item Lending</a></li>
                                                                             <li><a href="BookReturn.aspx">Item Return</a></li>                                 
                                                                         </ul>
                                                                    </li>
                                                                    <li><a href="#">Others</a>
                                                                        <ul>
                                                                            <li><a href="#">Other Items</a></li>
                                                                        </ul>
                                                                    </li>
                                                                   <%-- <li>
                                                                        <asp:LinkButton ID="lnbLogOut" runat="server" onclick="lnbLogOut_Click">LogOut</asp:LinkButton>
                                                                    </li>--%>
                                                                 </ul>
                                                            </div>
                                                    </td>
                                                </tr>
                                            </table>
                                        </td>
                                    </tr>
                                    <tr style="height:75%">
                                        <td>
                                            <table style="width:100%;height:320px; border:1;border-style:solid">
                                                <tr>
                                                    <td align="left" valign="top">
                                                        <div>
                                                        <asp:ScriptManager ID="ScriptManager1" runat="server"></asp:ScriptManager>
                                                            <asp:ContentPlaceHolder ID="ContentPlaceHolder1" runat="server">
                                   
                                                            </asp:ContentPlaceHolder>
                                                        </div>
                                                    </td>
                                                </tr>   
                                            </table>
                                        </td>
                                    </tr>
                                    <tr style="height:5%">
                                        <td>
                                            <table style="width:100%; border:1;border-style:solid">
                                                <tr>
                                                    <td>
                                                        Library Management Ltd
                                                    </td>
                                                </tr>
                                            </table>
                                        </td>
                                    </tr>
                                </table>
                                </td>
                                </tr>
                                </table>
                                </form>
                            </body>
                            </html>





                            ---------------   items view .aspx        ----------------

                            <%@ Page Language="C#" AutoEventWireup="true" MasterPageFile="~/LibraryR.Master" EnableEventValidation="true" CodeBehind="Items1.aspx.cs" Inherits="Library_Management_System.Items1" %>
                            <asp:Content ID="Content3" ContentPlaceHolderID="head" runat="server">
                            </asp:Content>

                            <asp:Content ID="Content4" ContentPlaceHolderID="ContentPlaceHolder1" runat="server">
                                <input type="hidden" id="ctrlPrefix" name="ctrlPrefix" value='<asp:Literal Runat=server ID=ctrlPrefix></asp:Literal>' />
                                <table style="background-color:#D8D8D8" border="0" width="100%">
                                <tr>
                                <td align="center" style="font-size:20px">
                                <asp:Label ForeColor="#0B3861" runat="server" Text="">
                                Item Management
                                </asp:Label>
                                </td>
                                </tr>
                                </table>
                               
                            <div>
                            <table>
                            <tr>
                            <td><asp:Label ID="Label1" runat="server">Item Type:</asp:Label></td>
                            <td>
                                <asp:DropDownList ID="ddItemType" AutoPostBack="true" runat="server" OnSelectedIndexChanged="onChangeItemType">
                                </asp:DropDownList>
                            </td>
                            <td><asp:Label ID="Label2" runat="server">Item Name:</asp:Label></td>
                            <td>
                                <asp:TextBox ID="txtSearchItemName" runat="server" Text=""></asp:TextBox>
                            </td>
                            <td>
                            <asp:LinkButton ID="LinkButton1" runat="server" Text="search" OnClientClick="return searchValidation()" OnClick="searchItems"></asp:LinkButton>
                            </td>
                            </tr>
                            </table>
                            </div>

                            <asp:UpdatePanel ID="gmaster" runat="server">
                            <ContentTemplate>
                            <div>
                                <asp:GridView AllowPaging="true"  PageSize="4" ID="employeeViewGrid"
                                    AutoGenerateColumns="false" ShowHeader="true" runat="server" OnPageIndexChanging="onPageChange"
                                     Width="100%" >
                              
                                         <RowStyle CssClass="rowStyle" />
                                         <AlternatingRowStyle CssClass="rowStyleAlternate" />
                                         <Columns>
                                         <asp:TemplateField HeaderStyle-CssClass="headerStyle">
                                         <HeaderTemplate>
                                            <font color="black">Name </font><font color="black"></font>
                                         </HeaderTemplate>
                                         <ItemTemplate>
                                         <font color="black">
                                         <a href='AddItem1.aspx?itemId=<%# Eval("itemId")%>'> <%# Eval("itemName")%> </a>
                                         </font>
                                         </ItemTemplate>
                                         </asp:TemplateField>
                                         </Columns>
                                         <Columns>
                                         <asp:TemplateField HeaderStyle-CssClass="headerStyle">
                                         <HeaderTemplate>
                                         <font color="black"> Count:</font>
                                         </HeaderTemplate>
                                         <ItemTemplate>
                                         <font color="black"><%# Eval("count")%></font>
                                         </ItemTemplate>
                                         </asp:TemplateField>
                                         </Columns>
                                         <Columns>
                                         <asp:TemplateField HeaderStyle-CssClass="headerStyle">
                                         <HeaderTemplate>
                                          <font color="black">Author</font>
                                         </HeaderTemplate>
                                         <ItemTemplate>
                                         <font color="black"><%# Eval("author")%></font>
                                         </ItemTemplate>
                                         </asp:TemplateField>
                                      
                                         </Columns>
                                          <Columns>
                                         <asp:TemplateField HeaderStyle-CssClass="headerStyle">
                                         <HeaderTemplate>
                                          <font color="black">Publisher</font>
                                         </HeaderTemplate>
                                         <ItemTemplate>
                                         <font color="black"><%# Eval("publisher")%></font>
                                         </ItemTemplate>
                                         </asp:TemplateField>
                                      
                                         </Columns>
                                        
                                      
                                    </asp:GridView>
                                </div>
                            </ContentTemplate>
                            </asp:UpdatePanel>
                            <div>
                                    <asp:Button ID="InsertButton" OnClick="onClickAdd" runat="server"  Text="Add"
                                        Height="28px" Width="51px" />
                                </div>


                            </asp:Content>