工作流程學習筆記(一)

來源:互聯網
上載者:User
這幾天在學習工作流程,照著史蒂芬的筆記做請假工作的例子過程中,遇到了一些問題,
其中一個問題困擾了我好幾天 。紀錄下來
第一個異常是設定資料庫的: org.apache.commons.dbcp.SQLNestedException: Cannot create JDBC driver of class '' for onnect URL 'null'
這個問題到網上一查很多相關的網友都遇到了這個問題,但是他們說的那些出錯的地方我都沒有錯
同事也幫我找,也感覺這麼配置不應該出現任何問題了,最後,感覺應該是和tomcat伺服器有關。
換了個版本果然問題不存在了,最後張姐協助我解決了這個問題,原來在設定資料庫的時候tomcat5.0和tomcat5.5有一些差別把他們貼出來,這個是5.5的,只需要在server.xml檔案中加入這段代碼就可以
<Context
  docBase="myfirstworkflow"

  path="/myfirstworkflow"
  reloadable="true">
    <Resource name="jdbc/test"
    auth="Container"
    type="javax.sql.DataSource"
    maxActive="100"
    maxIdle="30"
    maxWait="10000"
    driverClassName="net.sourceforge.jtds.jdbc.Driver"
    username="sa"
    password="syb"
    url="jdbc:jtds:sqlserver://localhost:1433/workflow"
    defaultAutoCommit="true"
    removeAbondoned="true"
    removeAbondonedTimeout="60"
    logAbondoned="true"
    />

</Context>
5.0的則麻煩一些
<Server port="8005" shutdown="SHUTDOWN" debug="0">

  <!-- Comment out these entries to disable JMX MBeans support -->
  <Listener className="org.apache.catalina.mbeans.ServerLifecycleListener"
            debug="0"/>
  <Listener className="org.apache.catalina.mbeans.GlobalResourcesLifecycleListener"
            debug="0"/>

  <GlobalNamingResources>

 
    <Environment name="simpleValue" type="java.lang.Integer" value="30"/>

    <!-- Editable user database that can also be used by
         UserDatabaseRealm to authenticate users -->
    <Resource name="UserDatabase" auth="Container"
              type="org.apache.catalina.UserDatabase"
       description="User database that can be updated and saved">
    </Resource>
    <ResourceParams name="UserDatabase">
      <parameter>
        <name>factory</name>
        <value>org.apache.catalina.users.MemoryUserDatabaseFactory</value>
      </parameter>
      <parameter>
        <name>pathname</name>
        <value>conf/tomcat-users.xml</value>
      </parameter>
    </ResourceParams>
       <Resource name="jdbc/test"
               auth="Container"
               type="javax.sql.DataSource"/>
<ResourceParams name="jdbc/test">
    <parameter>
      <name>factory</name>
      <value>org.apache.commons.dbcp.BasicDataSourceFactory</value>
    </parameter>

    <!-- Maximum number of dB connections in pool. Make sure you
         configure your mysqld max_connections large enough to handle
         all of your db connections. Set to 0 for no limit.
         -->
    <parameter>
      <name>maxActive</name>
      <value>100</value>
    </parameter>

    <!-- Maximum number of idle dB connections to retain in pool.
         Set to -1 for no limit.  See also the DBCP documentation on this
         and the minEvictableIdleTimeMillis configuration parameter.
         -->
    <parameter>
      <name>maxIdle</name>
      <value>30</value>
    </parameter>

    <!-- Maximum time to wait for a dB connection to become available
         in ms, in this example 10 seconds. An Exception is thrown if
         this timeout is exceeded.  Set to -1 to wait indefinitely.
         -->
    <parameter>
      <name>maxWait</name>
      <value>10000</value>
    </parameter>

    <!-- MySQL dB username and password for dB connections  -->
    <parameter>
     <name>username</name>
     <value>sa</value>
    </parameter>
    <parameter>
     <name>password</name>
     <value>syb</value>
    </parameter>

    <parameter>
       <name>driverClassName</name>
       <value>net.sourceforge.jtds.jdbc.Driver</value>
    </parameter>
    <parameter>
      <name>url</name>
      <value>jdbc:jtds:sqlserver://localhost:1433/workflow</value>
    </parameter>
  </ResourceParams>

  </GlobalNamingResources>
  <Service name="Catalina">
  <Connector
port="5566"               maxThreads="150" minSpareThreads="25" maxSpareThreads="75"
               enableLookups="false" redirectPort="8443" acceptCount="100"
               debug="0" connectionTimeout="20000"
               disableUploadTimeout="true" />

   
    <Connector port="8009"
               enableLookups="false" redirectPort="8443" debug="0"
               protocol="AJP/1.3" />

  
    <Engine name="Catalina" defaultHost="localhost" debug="0">

      <Logger className="org.apache.catalina.logger.FileLogger"
              prefix="catalina_log." suffix=".txt"
              timestamp="true"/>

      <Realm className="org.apache.catalina.realm.UserDatabaseRealm"
                 debug="0" resourceName="UserDatabase"/>

      <Host name="localhost" debug="0" appBase="webapps"
       unpackWARs="true" autoDeploy="true">

        <Logger className="org.apache.catalina.logger.FileLogger"
                 directory="logs"  prefix="localhost_log." suffix=".txt"
            timestamp="true"/>

<Context path="/myfirstworkflow" reloadable="true" docBase="/myfirstworkflow" >

 <ResourceLink   name="jdbc/test"   global="jdbc/test"   type="javax.sql.DataSource"/>  
  
</Context>

 </Host>

    </Engine>

  </Service>

</Server>
這樣配置,問題就解決了。
另一個問題:
javax.naming.NameNotFoundException: DefaultDS not bound
我原來配置的是DefaultDS資料來源,後來把這個資料來源改稱test了。但是控制台卻出現了這個異常。這個原因很簡單,是因為我沒有配置propertyset.xml檔案,重新設定了這個檔案後問題解決了。檔案內容如下
<propertysets>
    <propertyset name="jdbc" class="com.opensymphony.module.propertyset.database.JDBCPropertySet">
        <arg name="datasource" value="jdbc/test"/>
        <arg name="table.name" value="OS_PROPERTYENTRY"/>
        <arg name="col.globalKey" value="GLOBAL_KEY"/>
        <arg name="col.itemKey" value="ITEM_KEY"/>
        <arg name="col.itemType" value="ITEM_TYPE"/>
        <arg name="col.string" value="STRING_VALUE"/>
        <arg name="col.date" value="DATE_VALUE"/>
        <arg name="col.data" value="DATA_VALUE"/>
        <arg name="col.float" value="FLOAT_VALUE"/>
        <arg name="col.number" value="NUMBER_VALUE"/>
    </propertyset>
</propertysets>

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.