File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Web Services and the fly likes @WebMethod not found Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Java » Web Services
Bookmark "@WebMethod not found" Watch "@WebMethod not found" New topic
Author

@WebMethod not found

ahsan mir
Ranch Hand

Joined: Jul 17, 2006
Posts: 42
Hello,
i am writing a simple echo server(just the webservice).When i try to compile the 'build.xml' file , i get the following error.


*********************************************************************
C:\javaeetutorial5\examples\jaxws\helloservice>asant -f build.xml
Buildfile: build.xml

-pre-init:

init:

default-ear:

-pre-compile:

bpp-actual-compilation:
[echo] Compiling helloservice
[mkdir] Created dir: C:\javaeetutorial5\examples\jaxws\helloservice\build\we
b\WEB-INF\classes
[javac] Compiling 1 source file to C:\javaeetutorial5\examples\jaxws\hellose
rvice\build\web\WEB-INF\classes
[javac] C:\javaeetutorial5\examples\jaxws\helloservice\src\java\helloservice
\endpoint\Hello.java:31: package javax.jws does not exist
[javac] import javax.jws.WebMethod;
[javac] ^
[javac] C:\javaeetutorial5\examples\jaxws\helloservice\src\java\helloservice
\endpoint\Hello.java:32: package javax.jws does not exist
[javac] import javax.jws.WebService;
[javac] ^
[javac] C:\javaeetutorial5\examples\jaxws\helloservice\src\java\helloservice
\endpoint\Hello.java:35: cannot find symbol
[javac] symbol: class WebService
[javac] @WebService
[javac] ^
[javac] C:\javaeetutorial5\examples\jaxws\helloservice\src\java\helloservice
\endpoint\Hello.java:39: cannot find symbol
[javac] symbol : class WebMethod
[javac] location: class helloservice.endpoint.Hello
[javac] @WebMethod
[javac] ^
[javac] 4 errors

BUILD FAILED
C:\javaeetutorial5\examples\bp-project\command-line-ant-tasks.xml:89: Compile fa
iled; see the compiler error output for details.

Total time: 4 seconds

C:\javaeetutorial5\examples\jaxws\helloservice>

*************************************************************************

The following is my webservice:

//////////////////////////////////////////////////////////////////////
package helloservice.endpoint;

import javax.jws.WebMethod;
import javax.jws.WebService;


@WebService
public class Hello {
private String message = new String("Hello, ");

@WebMethod
public String sayHello(String name) {
return message + name + ".";
}
}

///////////////////////////////////////////////////////////////////

Any help would be appreciated.

Thanks
Peer Reynders
Bartender

Joined: Aug 19, 2005
Posts: 2906
My next action would be to determine which JAR contains the javax.jws package (with the WebService and WebMethod annotations) and determine whether that JAR is in the relevant class and/or build paths.

You haven't mentioned the SOAP stack that you are using. It's likely that you are using Axis 2.* but there are others that support JSR 181: Web Services Metadata for the Java(tm)Platform outside of JSR 224: JavaTM API for XML-Based Web Services (JAX-WS) 2.0.


"Don't succumb to the false authority of a tool or model. There is no substitute for thinking."
Andy Hunt, Pragmatic Thinking & Learning: Refactor Your Wetware p.41
ahsan mir
Ranch Hand

Joined: Jul 17, 2006
Posts: 42
hello,
the problem seemed to be related to what you mentioned.I was using J2ee SDK 1.4 and the sun application server 8 .I then tested it on the new J2ee SDK 5 and sun application server 9, & it did compiled.
have not worked in apache axis , is it easier to use and are ther any online tutorials like for the j2ee server and the Sun WSDP 2.


Thanks.
Peer Reynders
Bartender

Joined: Aug 19, 2005
Posts: 2906
Originally posted by ahsan mir:
I was using J2ee SDK 1.4 and the sun application server 8.


Well, annotations aren't supported until Java 5 (1.5). So strictly speaking J2EE 1.4 doesn't support it. That being said SUN did sneak the Java 5 Core into later versions of the J2EE SDK 1.4.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: @WebMethod not found
 
Similar Threads
Issue while deploying web service jwstutorial example CLI171
Error while deploying the war file using command "asant deploy"
Setting jars in class path
Sun JavaeeTutorial jaxB examples
Passing Files in Web Services