2013-08-03 9 views
0

Eclipse에서 웹 서비스 클라이언트를 개발 중입니다. 내가 받는다는의 wsimport 작업을 사용하여 웹 서비스 아티팩트를 생성합니다 (아래의 pom.xml 참조), 다음 주 방법과 같이 간단한 클라이언트를 썼다 : 불행하게도Eclipse에서 wsimport maven 목표를 사용하여 생성 된 웹 서비스 클라이언트를 실행하는 동안 ClassNotFoundException이 발생했습니다.

TeamsService service = new TeamsService(); 
Teams port = service.getTeamsPort(); 
List<Team> teams = port.getTeams(); 
for (Team team : teams) { 
    System.out.println("Team name: " + team.getName() + " (roster count: " + team.getRosterCount() + ")"); 
    for (Player player : team.getPlayers()) 
       System.out.println(" Player: " + player.getNickname()); 
} 

내가 이클립스 프로젝트를 실행 Java 애플리케이션으로서 ClassNotFoundException을 얻는다. 나는 exec : java 목표를 사용하여 클라이언트를 실행하려고 시도 했으므로 문제가 Eclipse 구성 (예 : m2e 플러그인 또는 클래스 경로)에 놓여 있다고 생각한다.

정말 도움이됩니다.

추신 : 저는 초보자입니다. 어쩌면 여기서 기본적인 것을 놓칠 수 있습니다. 간부 실행할 때

Exception in thread "main" java.lang.NoClassDefFoundError: com/sun/istack/localization/Localizable 
    at java.lang.ClassLoader.defineClass1(Native Method) 
    at java.lang.ClassLoader.defineClass(ClassLoader.java:792) 
    at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:142) 
    at java.net.URLClassLoader.defineClass(URLClassLoader.java:449) 
    at java.net.URLClassLoader.access$100(URLClassLoader.java:71) 
    at java.net.URLClassLoader$1.run(URLClassLoader.java:361) 
    at java.net.URLClassLoader$1.run(URLClassLoader.java:355) 
    at java.security.AccessController.doPrivileged(Native Method) 
    at java.net.URLClassLoader.findClass(URLClassLoader.java:354) 
    at java.lang.ClassLoader.loadClass(ClassLoader.java:424) 
    at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:308) 
    at java.lang.ClassLoader.loadClass(ClassLoader.java:357) 
    at java.lang.ClassLoader.defineClass1(Native Method) 
    at java.lang.ClassLoader.defineClass(ClassLoader.java:792) 
    at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:142) 
    at java.net.URLClassLoader.defineClass(URLClassLoader.java:449) 
    at java.net.URLClassLoader.access$100(URLClassLoader.java:71) 
    at java.net.URLClassLoader$1.run(URLClassLoader.java:361) 
    at java.net.URLClassLoader$1.run(URLClassLoader.java:355) 
    at java.security.AccessController.doPrivileged(Native Method) 
    at java.net.URLClassLoader.findClass(URLClassLoader.java:354) 
    at java.lang.ClassLoader.loadClass(ClassLoader.java:424) 
    at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:308) 
    at java.lang.ClassLoader.loadClass(ClassLoader.java:357) 
    at com.sun.xml.ws.client.WSServiceDelegate.<init>(WSServiceDelegate.java:208) 
    at com.sun.xml.ws.spi.ProviderImpl.createServiceDelegate(ProviderImpl.java:112) 
    at javax.xml.ws.Service.<init>(Service.java:77) 
    at ch01.team.TeamsService.<init>(TeamsService.java:42) 
    at ch01.team.Client.main(Client.java:7) 
Caused by: java.lang.ClassNotFoundException: com.sun.istack.localization.Localizable 
    at java.net.URLClassLoader$1.run(URLClassLoader.java:366) 
    at java.net.URLClassLoader$1.run(URLClassLoader.java:355) 
    at java.security.AccessController.doPrivileged(Native Method) 
    at java.net.URLClassLoader.findClass(URLClassLoader.java:354) 
    at java.lang.ClassLoader.loadClass(ClassLoader.java:424) 
    at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:308) 
    at java.lang.ClassLoader.loadClass(ClassLoader.java:357) 
    ... 29 more 

메이븐 로그 :

는 pom.xml 파일 :

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
    xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> 
    <modelVersion>4.0.0</modelVersion> 
    <groupId>com.foo</groupId> 
    <artifactId>JWSClients</artifactId> 
    <version>0.0.1-SNAPSHOT</version> 

    <dependencies> 

     <dependency> 
      <groupId>com.sun.xml.ws</groupId> 
      <artifactId>jaxws-rt</artifactId> 
      <version>2.2.8</version> 
      <scope>runtime</scope> 
     </dependency> 

    </dependencies> 

    <build> 
     <plugins> 
      <plugin> 
       <groupId>org.jvnet.jax-ws-commons</groupId> 
       <artifactId>jaxws-maven-plugin</artifactId> 
       <version>2.3</version> 
       <executions> 
        <execution> 
         <goals> 
          <goal>wsimport</goal> 
         </goals> 
        </execution> 
       </executions> 

       <configuration> 
        <wsdlUrls> 
         <wsdlUrl>http://localhost:8888/teams?wsdl</wsdlUrl> 
        </wsdlUrls> 
        <sourceDestDir>${basedir}/src/main/java</sourceDestDir> 
       </configuration> 
      </plugin> 

      <plugin> 
       <groupId>org.apache.maven.plugins</groupId> 
       <artifactId>maven-compiler-plugin</artifactId> 
       <version>3.1</version> 
       <configuration> 
        <source>1.7</source> 
        <target>1.7</target> 
       </configuration> 
      </plugin> 

     </plugins> 

     <pluginManagement> 
      <plugins> 
       <!--This plugin's configuration is used to store Eclipse m2e settings only. It has no influence on the Maven build itself.--> 
       <plugin> 
        <groupId>org.eclipse.m2e</groupId> 
        <artifactId>lifecycle-mapping</artifactId> 
        <version>1.0.0</version> 
        <configuration> 
         <lifecycleMappingMetadata> 
          <pluginExecutions> 
           <pluginExecution> 
            <pluginExecutionFilter> 
             <groupId> 
              org.jvnet.jax-ws-commons 
             </groupId> 
             <artifactId> 
              jaxws-maven-plugin 
             </artifactId> 
             <versionRange> 
              [2.3,) 
             </versionRange> 
             <goals> 
              <goal>wsimport</goal> 
             </goals> 
            </pluginExecutionFilter> 
            <action> 
             <ignore></ignore> 
            </action> 
           </pluginExecution> 
          </pluginExecutions> 
         </lifecycleMappingMetadata> 
        </configuration> 
       </plugin> 
      </plugins> 
     </pluginManagement> 
    </build> 

    <properties> 
     <encoding>UTF-8</encoding> 
    </properties> 
</project> 

스택 트레이스 자바

[INFO]                   
[INFO] ------------------------------------------------------------------------ 
[INFO] Building JWSClients 0.0.1-SNAPSHOT 
[INFO] ------------------------------------------------------------------------ 
[WARNING] The POM for org.eclipse.m2e:lifecycle-mapping:jar:1.0.0 is missing, no dependency information available 
[WARNING] Failed to retrieve plugin descriptor for org.eclipse.m2e:lifecycle-mapping:1.0.0: Plugin org.eclipse.m2e:lifecycle-mapping:1.0.0 or one of its dependencies could not be resolved: Failure to find org.eclipse.m2e:lifecycle-mapping:jar:1.0.0 in http://repo.maven.apache.org/maven2 was cached in the local repository, resolution will not be reattempted until the update interval of central has elapsed or updates are forced 
[INFO] 
[INFO] >>> exec-maven-plugin:1.2.1:java (default-cli) @ JWSClients >>> 
[INFO] 
[INFO] <<< exec-maven-plugin:1.2.1:java (default-cli) @ JWSClients <<< 
[INFO] 
[INFO] --- exec-maven-plugin:1.2.1:java (default-cli) @ JWSClients --- 
Team name: Abbott and Costello (roster count: 2) 
Player: Bud 
Player: Lou 
Team name: Marx Brothers (roster count: 3) 
Player: Chico 
Player: Groucho 
Player: Harpo 
Team name: Burns and Allen (roster count: 2) 
Player: George 
Player: Gracie 
[INFO] ------------------------------------------------------------------------ 
[INFO] BUILD SUCCESS 
[INFO] ------------------------------------------------------------------------ 
[INFO] Total time: 2.561s 
[INFO] Finished at: Sat Aug 03 16:52:19 COT 2013 
[INFO] Final Memory: 14M/154M 
[INFO] ------------------------------------------------------------------------ 

답변

0

을 일주일 전쯤에이 같은 웹 서비스를 만들었습니다. 이클립스에서 새 프로젝트를 만들고 패키지 ch01.teams.service와 ch01.teams.client를 만들었습니다 (패키지 이름은 책과 약간 다르지만 같은 생각입니다). 이것은 Maven을 다루는 것보다 훨씬 쉽습니다. 그리고 그것은 나를 위해 일했습니다.

Maven을 계속 사용하려면 com.sun.istack.localization.Localizable을 클래스 경로로 가져와야 할 수도 있습니다 (클래스 패스가 있는지 여부는 확실하지 않습니다). http://www.jarfinder.com/index.php/java/info/com.sun.istack.localization.Localizable으로 가면 jaxb-impl-2.1.8.jar에있는 것을 볼 수 있습니다. jar 파일을 다운로드하여 classpath에 넣을 수 있다면 잘 할 수 있습니다.