2012-06-02 4 views
1

문제가 있습니다. 내 앱에 스톱워치 디스플레이를 추가하고 싶습니다. 이 page을 참조로 사용했습니다. 필수 commons-scxml-0.9.jar 라이브러리 (소스 코드 포함)를 다운로드하고 추가했습니다. 이클립스에 오류가 없습니다하지만 난 슈퍼 클래스 (AbstractStateMachine)이 class 생성자에서, 그것을 디버깅 할 때이 명령으로 호출됩니다.스톱워치 생성자에 URL이 필요합니다. scxmlDocument

슈퍼 (StopWatch.class.getClassLoader()의 getResource ("조직/apache/commons/scxml/env/stopwatch.xml "));

하지만 수퍼 클래스 생성자는 속성을 갖지 않습니다. 최종 URL scxmlDocument이 있지만 만 나타납니다.

stopwatch.xml은 어떻게 보이나 어디에서 배치해야하는지 알고 있습니다. 최종 URL scxmlDocument은 어떻게 작성합니까?

나는 모든 것을 시도했지만 아무 것도 효과가 없었습니다.

감사합니다.

`<?xml version="1.0" ?> 

  <transition event="watch.start" target="running" /> 
    </state> 
    <state id="running"> 
      <transition event="watch.split" target="paused" /> 
      <transition event="watch.stop" target="stopped" /> 
    </state> 
    <state id="paused"> 
      <transition event="watch.unsplit" target="running" /> 
      <transition event="watch.stop" target="stopped" /> 
    </state> 
    <state id="stopped"> 
      <transition event="watch.reset" target="reset" /> 
    </state> 

`

+0

, 대신 단지 : 당신이 의존하는 jar 파일에 대해 아무것도 언급이 클래스 경로에 있는지 확인하지 않았지만

그리고 마지막으로, '크로노 미터 '사용? – CommonsWare

+0

나는 이것을 먼저 시험해 본다. 그러나 나는 크로노 미터로 시도 할 것이다. 제안 해 주셔서 감사합니다. – m4gnum

답변

0

귀하의 코드가 잘 보이는 : 내가 그것을 때문에 ID 속성의 오류를보고 일식 추가하는 경우

이, stopwatch.xml입니다. 런타임에 예외가 발생하는 경우 질문에 포함시켜야합니다. XML은 또한 처음 몇 줄과 마지막 줄을 제외했다는 것을 제외하고는 괜찮습니다. (의도적 이었습니까? 아니면 XML에 실제로이 줄이 누락 되었습니까?). 이것은 내 XML입니다 :

<?xml version="1.0"?> 
<!-- 
* Licensed to the Apache Software Foundation (ASF) under one or more 
* contributor license agreements. See the NOTICE file distributed with 
* this work for additional information regarding copyright ownership. 
* The ASF licenses this file to You under the Apache License, Version 2.0 
* (the "License"); you may not use this file except in compliance with 
* the License. You may obtain a copy of the License at 
* 
*  http://www.apache.org/licenses/LICENSE-2.0 
* 
* Unless required by applicable law or agreed to in writing, software 
* distributed under the License is distributed on an "AS IS" BASIS, 
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
* See the License for the specific language governing permissions and 
* limitations under the License. 
--> 
<scxml xmlns="http://www.w3.org/2005/07/scxml" 
     version="1.0" 
     initial="reset"> 

    <state id="reset"> 
     <transition event="watch.start" target="running"/> 
    </state> 

    <state id="running"> 
     <transition event="watch.split" target="paused"/> 
     <transition event="watch.stop" target="stopped"/> 
    </state> 

    <state id="paused"> 
     <transition event="watch.unsplit" target="running"/> 
     <transition event="watch.stop" target="stopped"/> 
    </state> 

    <state id="stopped"> 
     <transition event="watch.reset" target="reset"/> 
    </state> 

</scxml> 

XML 파일을 넣을 위치는 일반적으로 SRC 디렉토리에 넣습니다. Eclipse가 빌드를 수행 할 때 XML 파일로 수행 할 작업을 알지 못하므로 기본 동작은 컴파일 된 코드가있는 BIN 디렉토리로 복사하는 것입니다. 이 문제가 발생하려면 Project > Clean...해야 할 수도 있습니다. 이것은 런타임 환경이 일반적으로 이와 같은 리소스를 찾을 것으로 기대하는 곳입니다.

다음은 정말 좋은 속임수입니다. 모든 Windows 버전에서 개발할 경우 Microsoft의 믿을 수 없을만큼 훌륭한 Sysinternals 사이트 (http://technet.microsoft.com/en-US/sysinternals)로 이동할 수 있습니다. 여기서 멋진 프로세스 모니터 유틸리티를 찾을 수 있습니다. 이 무료 유틸리티를 다운로드, 설치 및 실행하십시오. 유틸리티 내에서 프로세스 모니터 필터를 만드십시오. Path | contains | stopwatch.xml이 필터가 사용 가능하고 다른 모든 (사전 정의 된) 필터가 사용 불가능으로 설정되어 있는지 확인하십시오.

그런 다음 컴파일 된 스톱워치 프로그램을 실행하십시오. 이 유틸리티는 응용 프로그램 (및 거기에 포함 된 모든 클래스 로더)의 모든 위치를 표시하여 stopwatch.xml을 찾습니다.

그런 다음 파일을 이동하거나 복사하여 응용 프로그램이 파일을 찾는 위치에 있는지 확인할 수 있습니다. 이 유틸리티는 J2EE 응용 프로그램 (예 : Tomcat, Websphere 등)을 작성할 때 발생하는 유사한 "자원을 찾을 수 없습니다"문제에 특히 유용합니다.이 고통의 모든 통해가는 이유가 있나요

commons-beanutils-1.9.2.jar 
commons-digester-2.1.jar 
commons-jexl-1.1.jar 
commons-logging-1.2.jar 
commons-scxml-0.9.jar 
log4j-1.2.17.jar 
xalan.jar