Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / General / January 2008

Tip: Looking for answers? Try searching our database.

annotation processing in eclipse

Thread view: 
stc - 04 Dec 2007 13:17 GMT
JDK 5
JDK EE 5
Eclipse 3.3.1.1

I'm trying to write simple test webservice with only one method that returns
some string. From what I've found on the net it seems as if it's enough to
put @WebService annotation for the class and annotation processor would
generate necessary files for deployment on application server.

I've enabled annotation processing for the project in Eclipse, left default
".apt_generated" source directory and chosen tools.jar from JDK EE as "JARs
that contain annotation processors".

But nothing happens when I build the project (whether it is clean build or
just manual build of a single Java class). What am I missing? I've found
some examples on the net but they all demonstrate how to write one's own
annotation processor and that's not what I need.
Hendrik Maryns - 04 Dec 2007 16:02 GMT
stc schreef:
> JDK 5
> JDK EE 5
[quoted text clipped - 4 lines]
> put @WebService annotation for the class and annotation processor would
> generate necessary files for deployment on application server.

Where did you find this?

> I've enabled annotation processing for the project in Eclipse, left default
> ".apt_generated" source directory and chosen tools.jar from JDK EE as "JARs
[quoted text clipped - 4 lines]
> some examples on the net but they all demonstrate how to write one's own
> annotation processor and that's not what I need.

I suppose the website you are talking about provides some tool to do this.

H.
Signature

Hendrik Maryns
http://tcl.sfs.uni-tuebingen.de/~hendrik/
==================
http://aouw.org
Ask smart questions, get good answers:
http://www.catb.org/~esr/faqs/smart-questions.html

stc - 04 Dec 2007 18:17 GMT
I've been looking into this subject today and from what I've gathered there
are several standard command-line tools provided by Sun (apt, wsgen...) that
do all the work of generating stubs, wsdl, xsd and other files necessary for
deploying webservice.

Annotation processor is a term mentioned there and Eclipse has some kind of
support for that. I must admit that I couldn't find one clear step-by-step
example, only parts of information I could barely use.

I managed to generate something using apt but I didn't get wsdl and xsd
files...
Lew - 05 Dec 2007 02:40 GMT
stc schreef:
>> I'm trying to write simple test webservice with only one method that returns
>> some string. From what I've found on the net it seems as if it's enough to
>> put @WebService annotation for the class and annotation processor would
>> generate necessary files for deployment on application server.

Hendrik Maryns wrote:
> Where did you find this?

I, too, am interested in the answer to Hendrik's question.  What is the answer?

Signature

Lew

stc - 05 Dec 2007 06:55 GMT
> stc schreef:
> >> I'm trying to write simple test webservice with only one method that
[quoted text clipped - 9 lines]
> I, too, am interested in the answer to Hendrik's question.  What is the
> answer?

Not on some specific website but all over the net. At least, that's what I
thought I found. NetBeans generates all files necessary to deploy webservice
just by adding @WebService annotation to the class so I thought Eclipse
could do the same.
Lew - 05 Dec 2007 15:07 GMT
>> stc schreef:
>>>> I'm trying to write simple test webservice with only one method that
[quoted text clipped - 12 lines]
> just by adding @WebService annotation to the class so I thought Eclipse
> could do the same.

Please cite a reference for the @WebService annotation.

Signature

Lew

Lew - 05 Dec 2007 15:14 GMT
>>> stc schreef:
>>>>> I'm trying to write simple test webservice with only one method
[quoted text clipped - 13 lines]
>> deploy webservice just by adding @WebService annotation to the class
>> so I thought Eclipse could do the same.

Annotations have to be processed by a processor aware of the annotations.  At
a minimum you need a library that implements JSR 181 in your project.  It
might be that Eclipse doesn't have logic to handle these annotations, but
perhaps there is a plugin that will remedy that.  It seems that NetBeans is
equipped to handle JSR 181 automagically for you right out of the box.

Signature

Lew

stc - 05 Dec 2007 15:37 GMT
> Annotations have to be processed by a processor aware of the annotations.
> At a minimum you need a library that implements JSR 181 in your project.
> It might be that Eclipse doesn't have logic to handle these annotations,
> but perhaps there is a plugin that will remedy that.  It seems that
> NetBeans is equipped to handle JSR 181 automagically for you right out of
> the box.

Eclipse has something under Project Properties - Java Compiler - Annotations
Processing but nothing happens when I configure it. Truth be told, there's
something "Plug-ins and JARs that contain annotation processors" and I put
JDK EE's tools.jar there (it works with apt command line utility) but maybe
it needs specifically written plug-in...
Lew - 05 Dec 2007 19:17 GMT
>> Annotations have to be processed by a processor aware of the annotations.
>> At a minimum you need a library that implements JSR 181 in your project.
[quoted text clipped - 8 lines]
> JDK EE's tools.jar there (it works with apt command line utility) but maybe
> it needs specifically written plug-in...

Usually I've found that just having the JAR with the annotation class
definitions in the project class path suffices.

Signature

Lew

Franz - 10 Jan 2008 15:04 GMT
Hi,

I have a similar problem: I have custom annotation, but eclipse says
"cannot be resolved to a type". But the strange is that it only occurs
on annotation, which has variables.

For example I have this annotation:
@XmlNode(tagName = "test")
public final class test { ... }

The corresponding annotation-interface is:
@Target(ElementType.TYPE)
@Retention(RetentionPolicy.RUNTIME)
public @interface XmlNode {
    String namespaceUri() default "http://www.test.com/test";
    String namespacePrefix() default "test";
    String tagName();
}

Any idea, why it is not working?

Thanks in advance,
Franz


Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.