Home

Yukun's Blog

解決例: 「ファイルから操作とエンティティを取得できません」 - Autoloader.php

釈然としない解決法ですが、よければご参照下さい。

error_require_autoloader

事象

Flex Builder 4でPHPとのデータコネクション設定を行う際に上図のエラーが発生。
使用したサンプルチュートリアル:
connect to data - Flex Test Drive | Adobe Developer Connection

エラーメッセージ

Zend Framework が正しくインストールされていて、プロジェクトの出力フォルダーにある amf_config.ini ファイルでパラメーター "amf.production" が true に設定されていないことを確認してください。
Warning: Error parsing C:\Program Files (x86)\VertrigoServ\www\TestDrive\TestDrive-debug/amf_config.ini on line 5 in C:\Program Files (x86)\VertrigoServ\www\TestDrive\TestDrive-debug\gateway.php on line 12

Warning: require_once(Zend/Loader/Autoloader.php) [function.require-once]: failed to open stream: No such file or directory in C:\Program Files (x86)\VertrigoServ\www\TestDrive\TestDrive-debug\gateway.php on line 27

Fatal error: require_once() [function.require]: Failed opening required 'Zend/Loader/Autoloader.php' (include_path='.;C:\Program Files (x86)\VertrigoServ\Smarty;C:/Program Files/ZendFramework/library') in C:\Program Files (x86)\VertrigoServ\www\TestDrive\TestDrive-debug\gateway.php on line 27

amf_config.ini

[zend]
;set the absolute location path of webroot directory, example:
;Windows: C:\apache\www
;MAC/UNIX: /user/apache/www
webroot =C:/Program Files (x86)/VertrigoServ/www

;set the absolute location path of zend installation directory, example:
;Windows: C:\apache\PHPFrameworks\ZendFramework\library
;MAC/UNIX: /user/apache/PHPFrameworks/ZendFramework/library
;zend_path =

[zendamf]
amf.production = false
amf.directories[]=TestDrive/services

gateway.php

<?php
ini_set("display_errors", 1);
$dir = dirname(__FILE__);
$webroot = $_SERVER['DOCUMENT_ROOT'];
$configfile = "$dir/amf_config.ini";

//default zend install directory
$zenddir = $webroot. '/ZendFramework/library';

//Load ini file and locate zend directory
if(file_exists($configfile)) {
	$arr=parse_ini_file($configfile,true);
	if(isset($arr['zend']['webroot'])){
		$webroot = $arr['zend']['webroot'];
		$zenddir = $webroot. '/ZendFramework/library';
	}
	if(isset($arr['zend']['zend_path'])){
		$zenddir = $arr['zend']['zend_path'];
	}
}

//
// Setup include path
	//add zend directory to include path
set_include_path(get_include_path().PATH_SEPARATOR.$zenddir);
// Initialize Zend Framework loader
require_once 'Zend/Loader/Autoloader.php';

include_pathの'.;C:\Program Files (x86)\VertrigoServ\Smarty;C:/Program Files/ZendFramework/library'から、'Zend/Loader/Autoloader.php'を開けませんというエラー。

include_path 先のフォルダ構成を確認すると確かに'Zend/Loader/Autoloader.php'がないのでエラーが発生するのは分かる。

解決法

amf_config.iniファイル中のwebrootパラメータをコメントアウトすると正常に設定が完了。
変更前

webroot =C:/Program Files (x86)/VertrigoServ/www

変更後

;webroot =C:/Program Files (x86)/VertrigoServ/www

原因

本来はC:/Program Files (x86)/VertrigoServ/www/ZendFramework/library/Zend/Loader/Autoloader.phpを参照をすべき所を、C:/Program Files/ZendFramework/library/Zend/Loader/Autoloader.phpを参照しようとしてエラーとなった。
webroot =C:/Program Files (x86)/VertrigoServ/wwwのはずが、どこで書き換わったのかな?

今回はサンプルを走らせるのを優先したので、原因究明はここで止めています><;

追記 - 2010/07/26

以下のようなエラーメッセージが出力された場合も、上記の原因と同一である場合があります。

error_require_autoloader2

Send failed
Channel.Connect.Failed error NetConnection.Call.BadVersion: :
url: 'http://localhost/TestDrive_add_charts_PHP/gateway.php'

ご参考まで。

Windows7高速化・軽量化Tips

備忘録として以下のWindows7の使用リソースの軽量化設定の手順を簡単に紹介します。

  1. プリフェッチを無効にする
  2. スーパーフェッチを無効にする
  3. セキュリティセンター機能の無効
  4. 自動デフラグ停止
  5. 使用しないWindowsの機能のアンインストール
  6. 自動ログオン設定

プリフェッチを無効にする

レジストリ:HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Session Manager\Memory Management\PrefetchParameters
のEnablePrefetcherの値を0にする。
Prefetchの無効化

スーパーフェッチを無効にする

スタート→コントロールパネル→管理ツール→サービス→Superfetchをダブルクリックし、スタートアップの種類を「無効」に設定し、サービスを停止する。
Superfetchサービス

Superfetchサービスの設定

セキュリティセンター機能の無効

スタート→コントロールパネル→管理ツール→サービス→Security Centerをダブルクリックし、スタートアップの種類を「無効」に設定し、サービスを停止する。
Security Centerサービス

自動デフラグ停止

スタート→アクセサリ→「ディスク デフラグ ツール」からスケジュール設定を無効化する。

使用しないWindowsの機能のアンインストール

スタート→コントロールパネル→プログラムと機能→Windowsの機能の有効化または無効化をクリック
Windowsの機能の有効化または無効化
ガジェットはバックグラウンドで常駐するので、使用しないのであれば、アンインストールした方が良い。

自動ログオン設定

スタート→ファイル検索で「netplwiz」を入力→実行
netplwiz_exe
「ユーザーアカウント」画面で下図のチェックボックスをオフにする。
ユーザーアカウント画面

Android: "Unable to open sync connection!" の対処例

上記のメッセージはAndroidアプリをEclipseから実機でデバッグする際にDDMS上に出力されたエラーです。

[2010-06-05 15:16:21 - pokeca] Failed to upload pokeca.apk on device '11223344'
[2010-06-05 15:16:21 - pokeca] java.io.IOException 発生: Unable to open sync connection!
[2010-06-05 15:16:21 - pokeca] Launch canceled!

根本原因は不明ですが、対処として下記の手順を試みると解決しました。

  1. コマンドライン上でadb kill-server
  2. Android端末の接続を解除する(USBケーブルを抜く)
  3. コマンドライン上でadb start-server
  4. Android端末をUSBで再接続する。
  5. DDMSで端末が正常に接続されているか確認する。
  6. アプリのデバッグを開始→正常に実行される(OK!)。

コマンド

C:\Users\yukun>adb kill-server

C:\Users\yukun>adb start-server
* daemon not running. starting it now *
* daemon started successfully *

C:\Users\yukun>

5の実行結果

Android端末のUSB接続確認

参考サイト

Java: インターフェースとローカルのIPv6, IPv4アドレスの取得 - NetworkInterfaceクラス

下記のコードはネットワークインターフェース情報取得し、IPv6とIPv4のアドレスを取得、表示するサンプルコードです。

ソースコード

import java.net.Inet4Address;
import java.net.Inet6Address;
import java.net.InetAddress;
import java.net.NetworkInterface;
import java.net.SocketException;
import java.util.ArrayList;
import java.util.Enumeration;
import java.util.HashMap;

/**
 * ネットワークインターフェースの取得
 */
public class InetAddressesInfo {
  private HashMap<NetworkInterface, ArrayList<InetAddress>> interfaceMap;

  public InetAddressesInfo() {
    interfaceMap = new HashMap<NetworkInterface, ArrayList<InetAddress>>();
  }

  public void getInterfaces() {
    interfaceMap.clear();
    try {
      Enumeration<NetworkInterface> interfaceList = NetworkInterface.getNetworkInterfaces();
      if (interfaceList == null) {
        System.out.println("Message: No interfaces found");
      } else {
        while (interfaceList.hasMoreElements()) {
          NetworkInterface iface = interfaceList.nextElement();
          Enumeration<InetAddress> addrList = iface.getInetAddresses();
          if (!addrList.hasMoreElements()) continue;
          ArrayList<InetAddress> iaddress = new ArrayList<InetAddress>();
          while (addrList.hasMoreElements())
            iaddress.add(addrList.nextElement());
          interfaceMap.put(iface, iaddress);
        }
      }
    } catch (SocketException se) {
      System.out.println("Error getting network interfaces: " + se.getMessage());
    }
  }

  public void show() {
    for (NetworkInterface n : interfaceMap.keySet()) {
      System.out.println("Interface " + n.getName() + ": ");
      for (InetAddress a : interfaceMap.get(n)) {
        System.out.print("\tAddress " + ((a instanceof Inet4Address ? "(IPv4)"
            : (a instanceof Inet6Address ? "(IPv6)" : "(?)"))));
        System.out.println(": " + a.getHostAddress());
      }
    }
  }

  public HashMap<NetworkInterface, ArrayList<InetAddress>> getInterfaceMap() {
    return interfaceMap;
  }

  public void setInterfaceMap(
      HashMap<NetworkInterface, ArrayList<InetAddress>> interfaceMap) {
    this.interfaceMap = interfaceMap;
  }

  public static void main(String[] args) {
    InetAddressesInfo i =  new InetAddressesInfo();
    i.getInterfaces();
    i.show();
  }

}

実行結果

Interface lo:
	Address (IPv6): 0:0:0:0:0:0:0:1
	Address (IPv4): 127.0.0.1
Interface net4:
	Address (IPv6): fe80:0:0:0:0:5efe:c0a8:10a%12
Interface net5:
	Address (IPv6): 2001:0:4137:9e76:8ae:1cf7:3f57:fef5
	Address (IPv6): fe80:0:0:0:8ae:1cf7:3f57:fef5%13
Interface eth3:
	Address (IPv6): 2001:c90:33d:21d4:919c:836b:2d1a:cf33
	Address (IPv6): 2001:c90:33d:21d4:8856:aef1:d0bd:db64
	Address (IPv6): fe80:0:0:0:919c:836b:2d1a:cf33%11
	Address (IPv4): 192.168.1.10

ドキュメント

NetworkInterface (Java Platform SE 6)

Many interrupted jobs

Whilst I was working in the office today, I was asked to work jobs intermittently by colleagues and business partners. In order to finish the jobs effectively, I prioritize them. After that, I start completing them in order.

This article was corrected by Satelle in Lang-8. Thank you very much.

Page 1 of 4012345...Last »

Home

バックナンバー
最近のコメント
最近のトラックバック
メタ情報

Return to page top