ホーム  会社情報 > 社員ブログ 牟田口 

誰かが少しでも役に立ったら大成功なブログ

プログラム関連の技術Tipsを主に記載します。
プログラム?という方は、煮ても焼いても食えない情報なので、別ページを見た方が幸せかもしれません。
 
12
2012/05/14new

validateのDateを使うとスラッシュ外れる

Tweet ThisSend to Facebook | by:牟田口 満
Calendar

--- 環境


NetCommons2.x系

--- 現象


maple の validate のDate チェックを使うと、日付のスラッシュ外れる。

yyyy/mm/dd ⇒ yyyymmdd

--- 対処方法


1.スラッシュ外れて欲しくないので、Dateソースをカスタマイズする。

・maple の validate のDateソース

netcommons\maple\validator\Validator_Date.class.php

-- 52行目付近コメントアウト

        switch (_INPUT_DATE_FORMAT) {
           case "Y/m/d":
                $check = checkdate($matches[2], $matches[3], $matches[1]);
//                $dateString = $matches[1]. $matches[2]. $matches[3];
                break;
            case "m/d/Y":
                $check = checkdate($matches[1], $matches[2], $matches[3]);
//                $dateString = $matches[3]. $matches[1]. $matches[2];
                break;
            case "d/m/Y":
                $check = checkdate($matches[2], $matches[1], $matches[3]);
//                $dateString = $matches[3]. $matches[2]. $matches[1];
                break;
        }
        if (!$check) {
            return $errStr;
        }
       
//        $container =& DIContainerFactory::getContainer();
//        $request =& $container->getComponent("Request");
//        $key = $this->getKeys(0);
//        $request->setParameter($key, $dateString);
       

        return;



2.スラッシュ外れて欲しくないので、コピーしてカスタマイズする。

・maple の validate のDateソース(コピー元)

netcommons\maple\validator\Validator_Date.class.php

・(コピー先)

netcommons\maple\validator\Validator_Date2.class.php
// 1.の修正入れる

-- maple.ini

[ValidateDef]
input_name_hoge.date2 ="1:lang._invalid_date,ほげ"


3.スラッシュ外れて欲しくないので、使いたいモジュールのvalidateにコピーして独自実装する。

・maple の validate のDateソース(コピー元)

netcommons\maple\validator\Validator_Date.class.php

・(コピー先)

netcommons\webapp\modules\モジュール名\validator\Validator_Date.class.php
// 1.の修正入れる
// クラス名変更(20行目)

class Validator_Date extends Validator
⇒ class モジュール名_Validator_Date extends Validator

-- maple.ini

[ValidateDef]
input_name_hoge.モジュール名.date ="1:lang._invalid_date,ほげ"

16:55 | 投票する | 投票数(0) | トラックバック(0)
2012/02/02

スーパーセキュリティZEROでNetCommonsで画像添付ができない問題の対処

Tweet ThisSend to Facebook | by:牟田口 満
--- 環境

NetCommons2.3.3.0
スーパーセキュリティZERO Build 15.0.33
windows XP SP3
windows Vista SP1

--- ブラウザ

IE
FireFox
Chorme

--- 現象

NetCommonsで画像を添付しようとWYSIWYGエディタの画像ボタンを押したところ、
パッと表示されて、画像操作の小ウィンドウが閉じてしまう。
amazonボタンも同様だった。

--- 経緯

そういえばウィルス対策ソフト「スーパーセキュリティZERO」を新しく入れたな~。
なんかブラウザの上部に変なポッチ「スーパーセキュリティツールバー」があるなと思った。
ブラウザ文字化けの不具合もあったし、もしかして悪さしてね?と疑った。


変なポッチ「スーパーセキュリティツールバー」


ポッチを押すとこうなる

--- 対応

1.スーパーセキュリティZEROの設定変更

スーパーセキュリティZERO >
 設定>
  プライバシーコントロール>
   フィッシング対策>
"スーパーセキュリティツールバーを表示する"を「OFF」にする。

2.ブラウザのリロード(Ctrl+F5)
で変なポッチ「スーパーセキュリティツールバー」が消えてれば対応完了。

--- 推測

スーパーセキュリティツールバーが表示ついてれば、どのブラウザのバージョンでも発生すると思う。
大方、ポップアップ広告抑止あたりが悪さをして、Ajaxのポップアップまで抑止してるんだろう。

--- 蛇足:感想

Bitdefenderだと思って信頼してたのに、僕を裏切ったんだ。絶対に許さない!絶対にだっ!
と言いたかっただけで、ウィルスソフトにチョップしてやりたい。
でも買った弱みで使い続けるんだけどね。
更新料不要で良いんだけどな~。改善を生暖かく期待してます。

13:21 | 投票する | 投票数(0) | トラックバック(0)
2012/02/01

mysqldumpコマンドについて調べてみた

Tweet ThisSend to Facebook | by:牟田口 満
mysqldumpコマンドを使うと、指定してないのに drop table が入る。
嬉しいんだけど、なんで?というので調べてみた。

--- 抜粋

MySQL :: MySQL 5.1 リファレンスマニュアル :: 7.12 mysqldump   データベースバックアッププログラム
mysqldumpの中には他オプションをグループ化した略記法となっているものがあります。--optや--compactはこれに分類されるものです。例えば、--optを使用することは--add-drop-table --add-locks --create-options --disable-keys --extended-insert --lock-tables --quick --set-charsetを指定したのと同じことです。MySQL 5.1以降、--optが表すオプションは全てデフォルトで有効化されています。これは、--optがデフォルトで有効なためです。

--- 要約

・デフォルトで--optが有効。
・--optはオプションをグループ化したもの。そのグループの中に--add-drop-tableも含まれていた。


どうでもいい蛇足:
自分の経験値が+10あがった。
いつレベルアップするかは、自分も教えて欲しい。


14:38 | 投票する | 投票数(0) | トラックバック(0)
2012/01/18

ApacheとTomcatを共存させるためのコネクタ

Tweet ThisSend to Facebook | by:牟田口 満

ApacheとTomcatを共存させるためにコネクタが必要。
だけどコネクタが色々あって混乱。なのでまとめる。(2012/01/18現在)

  • (新)mod_proxy_ajp  : Apache2.2系にバンドルされている。
  • (古)mod_Jk               : Apache2.0以前はmod_jkモジュールを利用
  • (古)mod_Jk2             : 開発停止(少なくとも2005/04以前に開発停止)
  • (古)mod_webapp     : 開発停止(少なくとも2003/11以前に開発停止)


--- 結論

Apache2.2系を使っているのでmod_proxy_ajpを使う。


--- メモ


・mod_proxy_ajpを使うとAJP/1.3のプロトコルで通信できる。

・TomcatはデフォルトでAJP/1.3コネクタを持っている。

・AJPとは - はてなキーワード(http://d.hatena.ne.jp/keyword/AJP)より抜粋。
 Apache Jserv Protocolの略。WebアプリケーションサーバのTomcatをApache Web Serverと連携させる際に使うプロトコル。  

 

--- 設定の参考

下記サイトを参照しながら実施する。


Tomcatとの連携(mod_proxy_ajp) - Apache入門
http://www.adminweb.jp/apache/tomcat/

--- 参考


[Think IT] 第9回:Tomcatと外部のプログラムを連携させよう! (1-3)
http://thinkit.co.jp/free/article/0708/2/9/


mod_jk と mod_jk2 について - Java Solution - @IT
http://www.atmarkit.co.jp/bbs/phpBB/viewtopic.php?topic=20655&forum=12


Webapp    ※mod_webapp
http://www.nina.jp/server/slackware/tomcat/webapp.html




22:37 | 投票する | 投票数(0) | トラックバック(0)
2011/12/15

Chandler ServerのDBをMySQLに切替

Tweet ThisSend to Facebook | by:牟田口 満

Chandler ServerのDBを「Derby」→「MySQL」に切替


--- 参考

Chandler Wiki  Server Bundle Startup Configuration(Google翻訳)
http://translate.google.co.jp/translate?hl=ja&sl=auto&tl=ja&u=http%3A%2F%2Fchandlerproject.org%2FDocumentation%2FServerBundleStartupConfiguration%23MySQL%205%20

-- 抜粋(原文)

Chandler Wiki  Server Bundle Startup Configuration
http://chandlerproject.org/Documentation/ServerBundleStartupConfiguration#MySQL 5

1.Create a new database ("cosmo" for instance) on a MySQL 5 server. Make sure the default charset is utf8, and the default table engine is InnoDB.
・mysql -uroot -e"create database cosmo character set utf8"
2.Edit $OSAFSRV_HOME/etc/cosmo.properties and change the property cosmo.hibernate.dialect to org.osaf.cosmo.hibernate.CosmoMySQL5InnoDBDialect.
3.Edit $OSAFSRV_HOME/tomcat/conf/Catalina/localhost/chandler.xml
・Comment out the <Resource> definition for the Derby datasource, and uncomment the example <Resource> definition for a MySQL datasource
・Set the datasource properties to match your MySQL database server by editing the url entry and change [server] to your server name (most likely localhost) and change [db] to the name of the MySQL database you created for Cosmo.
・Make sure your username and password entries match the MySQL user information
4.Start Cosmo and the database schema will automatically be created the first time. 

-- 適当翻訳

1.MySQL 5のサーバー上に新しいデータベースを(たとえば、"cosmo")を作成するぞ。デフォルトの文字セットはUTF8、およびデフォルトのテーブルのエンジンがInnoDBテーブル。

mysql -uroot -e"create database cosmo character set utf8"

2. $OSAFSRV_HOME/etc/cosmo.propertiesを編集。下記プロパティに変更してね。変更しなきゃ暴れるぞ。

cosmo.hibernate.dialect=org.osaf.cosmo.hibernate.CosmoMySQL5InnoDBDialect

※ $OSAFSRV_HOME は /home/ユーザー/chandler/osaf-server-bundle-1.1.0/ に置換えて読む。

3. $OSAFSRV_HOME/tomcat/conf/Catalina/localhost/chandler.xml を編集。

39~42行目のDerbyをコメントアウト。

    <!-- Derby -->
    <Resource name="jdbc/cosmo" type="javax.sql.DataSource" maxActive="100"
              maxIdle="30" maxWait="10000" username="sa" password=""
                driverClassName="org.apache.derby.jdbc.EmbeddedDriver"
                url="jdbc:derby:db;create=true" />

    <!-- Derby -->
  <!--
    <Resource name="jdbc/cosmo" type="javax.sql.DataSource" maxActive="100"
              maxIdle="30" maxWait="10000" username="sa" password=""
                driverClassName="org.apache.derby.jdbc.EmbeddedDriver"
                url="jdbc:derby:db;create=true" />
    -->          

その下のMySQLのコメントアウトをはずして有効化

    <!-- MySQL -->
  <Resource name="jdbc/cosmo" type="javax.sql.DataSource" maxActive="100"
            maxIdle="30" maxWait="10000" username="[user]"
            password="[pass]" defaultAutoCommit="false"
                driverClassName="com.mysql.jdbc.Driver"
                url="jdbc:mysql://[server]:3306/[db]?useUnicode=true&amp;characterEncoding=UTF-8" />

    <!-- MySQL -->
  <Resource name="jdbc/cosmo" type="javax.sql.DataSource" maxActive="100"
            maxIdle="30" maxWait="10000" username="hogeuser"
            password="hogepass" defaultAutoCommit="false"
                driverClassName="com.mysql.jdbc.Driver"
                url="jdbc:mysql://localhost:3306/cosmo?useUnicode=true&amp;characterEncoding=UTF-8" />


--- chandler再起動

$ ./chandler/osaf-server-bundle-1.1.0/bin/osafsrvctl stop
$ ./chandler/osaf-server-bundle-1.1.0/bin/osafsrvctl start


--- ブラウザで確認

http://さくらVPSのホスト名:8080/chandler/welcome


Chandler ServerのDBを「Derby」→「MySQL」に切替作業をしていた時に遭遇したエラー。


荒っぽい方法だが、DBを別名で作り直して再設定すると解消した。
例えば
  1. Dbをcosmoで作成していたら、cosmo2 のDbを新規作成。
  2. $OSAFSRV_HOME/tomcat/conf/Catalina/localhost/chandler.xml の、MySQLのurl="jdbc:mysql://localhost:3306/[server]?useUnicode=true&amp;characterEncoding=UTF-8" の[server]部分を cosmo2 に編集
  3. chandler再起動

--- エラーログ($OSAFSRV_HOME/logs/osafsrv.log)

2011-12-14 15:56:56,042 INFO  [LifecycleLoggerListener] Chandler Server 1.1.0 starting
2011-12-14 15:56:58,726 INFO  [CosmoPropertyPlaceholderConfigurer] Loading properties file from URL [file:etc/cosmo.properties]
2011-12-14 15:57:12,539 INFO  [DbInitializer] found schema version null
2011-12-14 15:57:12,539 ERROR [DbInitializer] Schema version does not match (null:160
2011-12-14 15:57:12,542 ERROR [[/chandler]] クラス org.osaf.cosmo.db.DbListener のリスナインスタンスにコンテキスト初期化イベントを送信中の例外です
java.lang.RuntimeException: Schema version found in database does not match schema version required by server
    at org.osaf.cosmo.db.DbInitializer.checkSchemaVersion(DbInitializer.java:150)
    at org.osaf.cosmo.db.DbInitializer.initialize(DbInitializer.java:81)
    at org.osaf.cosmo.db.DbListener.contextInitialized(DbListener.java:58)
    at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:3729)
    at org.apache.catalina.core.StandardContext.start(StandardContext.java:4187)
    at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:759)
    at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:739)
    at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:524)
    at org.apache.catalina.startup.HostConfig.deployDescriptor(HostConfig.java:608)
    at org.apache.catalina.startup.HostConfig.deployDescriptors(HostConfig.java:535)
    at org.apache.catalina.startup.HostConfig.deployApps(HostConfig.java:470)
    at org.apache.catalina.startup.HostConfig.start(HostConfig.java:1122)
    at org.apache.catalina.startup.HostConfig.lifecycleEvent(HostConfig.java:310)
    at org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(LifecycleSupport.java:119)
    at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1021)
    at org.apache.catalina.core.StandardHost.start(StandardHost.java:718)
    at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1013)
    at org.apache.catalina.core.StandardEngine.start(StandardEngine.java:442)
    at org.apache.catalina.core.StandardService.start(StandardService.java:450)
    at org.apache.catalina.core.StandardServer.start(StandardServer.java:709)
    at org.apache.catalina.startup.Catalina.start(Catalina.java:551)
    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:294)
    at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:432)
2011-12-14 15:57:12,548 DEBUG [StandardUserService] getting user root
2011-12-14 15:57:12,596 ERROR [[/chandler]] クラス org.osaf.cosmo.ui.config.ConfigurationListener のリスナインスタンスにコンテキスト初期化イベントを送信中の例外です
java.lang.IllegalStateException: overlord not in database
    at org.osaf.cosmo.ui.config.ServletContextConfigurer.setServerAdmin(ServletContextConfigurer.java:60)
    at org.osaf.cosmo.ui.config.ServletContextConfigurer.configure(ServletContextConfigurer.java:50)
    at org.osaf.cosmo.ui.config.ConfigurationListener.contextInitialized(ConfigurationListener.java:53)
    at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:3729)
    at org.apache.catalina.core.StandardContext.start(StandardContext.java:4187)
    at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:759)
    at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:739)
    at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:524)
    at org.apache.catalina.startup.HostConfig.deployDescriptor(HostConfig.java:608)
    at org.apache.catalina.startup.HostConfig.deployDescriptors(HostConfig.java:535)
    at org.apache.catalina.startup.HostConfig.deployApps(HostConfig.java:470)
    at org.apache.catalina.startup.HostConfig.start(HostConfig.java:1122)
    at org.apache.catalina.startup.HostConfig.lifecycleEvent(HostConfig.java:310)
    at org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(LifecycleSupport.java:119)
    at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1021)
    at org.apache.catalina.core.StandardHost.start(StandardHost.java:718)
    at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1013)
    at org.apache.catalina.core.StandardEngine.start(StandardEngine.java:442)
    at org.apache.catalina.core.StandardService.start(StandardService.java:450)
    at org.apache.catalina.core.StandardServer.start(StandardServer.java:709)
    at org.apache.catalina.startup.Catalina.start(Catalina.java:551)
    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:294)
    at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:432)
2011-12-14 15:57:12,597 ERROR [StandardContext] Error listenerStart
2011-12-14 15:57:12,597 ERROR [StandardContext] 以前のエラーのためにコンテキストの起動が失敗しました [/chandler]
2011-12-14 15:57:12,608 INFO  [LifecycleLoggerListener] Chandler Server 1.1.0 stopping
2011-12-14 15:57:13,543 INFO  [Catalina] Server startup in 18774 ms

--- 調査

Re: [chandler-users] Error on Cosmo server startup(Google翻訳)
http://translate.google.co.jp/translate?hl=ja&sl=auto&tl=ja&u=http%3A%2F%2Fwww.mail-archive.com%2Fchandler-users%40osafoundation.org%2Fmsg01246.html

-- 抜粋(原文)

Re: [chandler-users] Error on Cosmo server startup
http://www.mail-archive.com/chandler-users@osafoundation.org/msg01246.html

You have to erase the database tables if everything fails in the first 
startup...
The second time, the server things that the database is ok, perhaps only 
cheching if the table are created or something similar....


→ユー、DB切替ちゃいなよと言ってる風。これをヒントに作業をした。


Log of #osaf-qa for 20070426, from 0000h to 2400h(Google翻訳)
http://translate.google.co.jp/translate?hl=ja&sl=auto&tl=ja&u=http%3A%2F%2Fchandlerproject.org%2Fscript%2FgetIrcTranscript.cgi%3Fchannel%3Dosaf-qa%26date%3D20070426

-- 抜粋(原文)

Log of #osaf-qa for 20070426, from 0000h to 2400h
http://chandlerproject.org/script/getIrcTranscript.cgi?channel=osaf-qa&date=20070426

14:22    admc >    java.lang.RuntimeException: Schema version does not match server version
14:22    admc >     at org.osaf.cosmo.db.DbInitializer.checkSchemaVersion(DbInitializer.java:147
14:23    bear >    that's from the mysql having been setup from a checkpoint
14:23    bear >    the checkpoint version/schema # is different than the 0.6.1 version/schema# only because of the text
14:23    bear >    the checkpoint is 0.6.1-CP-....
14:23    bear >    and 0.6.1 just has 0.6.1
14:24    bear >    I wonder if there is a way to change the schema # in mysql
14:28    admc >    well wiping mysql is fine
14:28    admc >    let me try that


→MySQLのチェックポイントのバージョン、スキーマずれ?を指摘している。
多分原因はコレなんだけど、時間の関係でこの案を深く追っていない。すまんな。

荒っぽい対応方法その2、Chandler Server再インストール。たぶんいけるじゃないかと思うが、試してない。

13:28 | 投票する | 投票数(0) | トラックバック(0)
12


〒 135-0062 東京都江東区東雲 1-9-41-3301
tel: 090-1699-2746
email: info@opensource-workshop.jp