Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Jetty8 servlet3 annotation support #85

Closed
GoogleCodeExporter opened this issue Jul 7, 2015 · 26 comments
Closed

Jetty8 servlet3 annotation support #85

GoogleCodeExporter opened this issue Jul 7, 2015 · 26 comments

Comments

@GoogleCodeExporter
Copy link

Please allow create run/debug configuration for jetty 8.x when web.xml id 
missed (it is not error for api version 3.0).


Original issue reported on code.google.com by asuk...@gmail.com on 25 Jul 2011 at 12:24

@GoogleCodeExporter
Copy link
Author

Sorry , I didn't get your question from you description, 
could you explain more on this one?

At least how to reproduce it and what's the error message?


Original comment by tonylovejava on 25 Jul 2011 at 4:10

@GoogleCodeExporter
Copy link
Author

Regarding to servlet api 3.0 web.xml can be ommited. It means I can create 
run/debug configuration for jetty 8.x without web.xml in WEB-INF folder. With 
current version of plugin it is impossible.

Original comment by asuk...@gmail.com on 25 Jul 2011 at 4:13

@GoogleCodeExporter
Copy link
Author

ok , got you.

I will try to remove it and test with servlet-api 3.0 project.

Original comment by tonylovejava on 25 Jul 2011 at 4:23

@GoogleCodeExporter
Copy link
Author

I added a comment to issue#55, but that is closed. I'll repeat it here (and 
yes, I also notice the problem with the requirement of a web.xml file):

The Jetty8 configuration that RJR makes apparently doesn't include 
annotation-processing (@WebServlet - drop web.xml entirely), which probably is 
one of the most defining features of Servlet 3.

To enable a default jetty 8 install to run annotations, you apparently need to 
start it as such:

java -jar start.jar OPTIONS=annotations,plus etc/jetty-plus.xml

This seems to sticks in a couple of jars (these aren't missing), and includes 
the annotation processing config for Jetty 8 (which seemingly is missing).

Original comment by en...@stolsvik.com on 28 Jul 2011 at 11:38

@GoogleCodeExporter
Copy link
Author

Here's Servlet that, if put on the webapp's classpath, should just "magically 
appear" on path /test


package test;

import java.io.IOException;

import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

@SuppressWarnings("serial")
@WebServlet(name = "TestServletName", urlPatterns = { "/test" })
public class TestServlet extends HttpServlet {
    public void doGet(HttpServletRequest req, HttpServletResponse res)
            throws IOException {
        res.getOutputStream().println("test output!");
    }
}

Original comment by en...@stolsvik.com on 28 Jul 2011 at 11:45

@GoogleCodeExporter
Copy link
Author

ok , I will take them all before we release 1.3 this weekend. ;)

Thanks for reporting issues. 

Original comment by tonylovejava on 29 Jul 2011 at 4:16

  • Changed state: Accepted

@GoogleCodeExporter
Copy link
Author

Awesome, quick response! ;-)

Original comment by en...@stolsvik.com on 29 Jul 2011 at 6:53

@GoogleCodeExporter
Copy link
Author

[deleted comment]

1 similar comment
@GoogleCodeExporter
Copy link
Author

[deleted comment]

@GoogleCodeExporter
Copy link
Author

Btw: An option to consider, is to enable the user to define additional jetty 
config files, as the 'etc/jetty-plus.xml' does above. That would a) have 
enabled me to "fix" this particular problem myself, and b) tailor the jetty 
server that is started to fit my needs.

Actually, I do feel that you should consider to /not/ programmatically define 
the jetty-server that is started by RJR, /but instead/ use a default jetty xml 
file to do this - which, under advanced options, could be exchanged with a user 
defined one. THEN, in addition, one should be able to include overrides.

This would be just like the 'jetty.jar' starter itself does.

This particular suggestion is not Jetty 8 specific, and is similar to  issue#9 
. Reading it again, I actually think it is identical! Note how   issue#9 
-comment#10 requests the same "Jetty Plus" config that I do here in comment#4 
(but that for jetty 6.)

Original comment by en...@stolsvik.com on 29 Jul 2011 at 7:14

@GoogleCodeExporter
Copy link
Author

About using a jetty.xml, I will take it into consider , but there's still some 
complicated part in the jetty server , since we do some resource mapping for 
linked resource, I am not sure if that's a easy one for converting to jetty.xml.

And in most case we meet so far, it's good enough to use the run configuration 
way,
we should have some use-case that really need a setup jetty.xml first.

I will think more/review the code for the jetty.xml after we release 1.3 , 
currently I don't have a good solution to handle it.:P


But surely we will handle the servlet3 and web.xml issue in 1.3 first.

Original comment by tonylovejava on 29 Jul 2011 at 10:03

@GoogleCodeExporter
Copy link
Author

For some reason I can't get the Jetty work even I setup a config in the code,
would you mind to provide a workable jetty.xml to help me test it ?

Anyway I think we will delay the annotation support to 1.3.1 , 
since it's more a complicated one then my image.  :P

It's easy to remove the web.xml detection ,add those jars in the classpath , 
and setup config classes in the code, but it's not working for some reason ,
so we need to test it more carefully and to be sure it's stable enough.

Original comment by tonylovejava on 30 Jul 2011 at 11:48

@GoogleCodeExporter
Copy link
Author

*Please* don't delay this. I really need this for the project I am embarking 
on, literally monday morning! :-)

You don not need to remove any jars at all - all jars can be included, as you 
do.

Have you got it working on the command line? I do not need to provide you with 
a jetty.xml, as I have never made one - I use the one provided in the jetty 
distribution.

Using the command-line I provided in comment#4, the Servlet I provided in 
comment#5 runs just fine, with no web.xml in the webapp, only the class 
residing in the webapp/WEB-INF/classes. (To test whether the webapp works at 
all, add a web.xml that defines another Servlet using another servletname, the 
same class, but on a different path.)

As I envisioned this, it should just be a matter of (in this first round) 
programmatically adding the same config processors that is added in the 
distribution-provided jetty-plus.xml. Just check that file up, it is a very 
tiny.

In a later stage, you definitely should look into using an user-overridable 
approach, possibly like I suggested in issue#9.

Original comment by en...@stolsvik.com on 31 Jul 2011 at 7:47

@GoogleCodeExporter
Copy link
Author

Ok , let me try if I could get it working in nightly version. :)

Original comment by tonylovejava on 31 Jul 2011 at 11:50

@GoogleCodeExporter
Copy link
Author

Ah ha! Finally got it working after I turn on the debugging mode and traced 
some details.

There's still something need to be mentioned.


1.I miss two dependency jars for the annotation , 
javax.annotation_1.1.0.v201105051105.jar
org.objectweb.asm_3.3.1.v201101071600.jar

That's the first reason for it's not working for me yesterday , 
I only find the asm , but not the javax.annotation since it's a hidden error 
message.

2.The AnnotationConfiguration 

It required to place your classes in WEB-INF/classes or the jars in WEB-INF/lib 
, actually that make sense for general web application ,but not the one we use 
for RunJettyRun , our classes files is actually depending on the JDT target 
output folder.

I try to copy the classes to WEB-INF/classes , then it working.

More reference 
http://download.eclipse.org/jetty/8.0.0.M3/xref/org/eclipse/jetty/osgi/annotatio
ns/AnnotationConfiguration.html

It's now the critical point for AnnotationConfiguration now , still looking for 
if there's any document could allow us to set a attribute to scan those classes.

Or I will try to create a my own implementation for RJR application , hope that 
could be done gracefully. :P

Original comment by tonylovejava on 1 Aug 2011 at 12:43

@GoogleCodeExporter
Copy link
Author

The one is the correct reference.
http://download.eclipse.org/jetty/8.0.0.M3/xref/org/eclipse/jetty/annotations/An
notationConfiguration.html

Original comment by tonylovejava on 1 Aug 2011 at 6:37

@GoogleCodeExporter
Copy link
Author

Yes, I had a hunch this might become a problem. But it is actually fixable, or 
at least hackable, by specifically stating in the project settings that the 
eclipse-build output folder shall be WEB-INF/classes.

However, any servlets in the project's referenced jars won't then be loaded.

Amending the AnnotationConfiguration to read through all of the 
run-configuration's Classpath (including jars) seems to be doable, as all 
methods are overridable. But it might be a bit difficult to do this in a 
Servlet 3.0 correct way, as there really are no such correct way..!

Original comment by en...@stolsvik.com on 1 Aug 2011 at 8:08

@GoogleCodeExporter
Copy link
Author

I know , it only takes time to survey it and work with it, lol.

Actually I have done this with my own AnnotationConfiguration.

You could try it on our nightly update-site ,here's the reference to nightly.
http://code.google.com/p/run-jetty-run/wiki/Nightly?ts=1312189791&updated=Nightl
y


For more details for how to debug if need.

Setup the two vm arguments to enable Jetty debugging log:
-Dorg.eclipse.jetty.start.DEBUG=true  
-Dorg.eclipse.jetty.util.log.stderr.DEBUG=true

And the log will show up  like this sample
---
2011-08-01 17:06:21.394:DBUG::parsing annotations
......
2011-08-01 17:06:21.461:DBUG::Scanning all classses for annotations: 
webxmlVersion=3 configurationDiscovered=true
2011-08-01 17:06:21.461:DBUG::Scanning container jars
2011-08-01 17:06:21.462:DBUG::Scanning classes in WEB-INF/classes
2011-08-01 17:06:21.464:DBUG::scanning RJR classes for 
annotation:C:\runtime-EclipseApplication\test1\build\classes
2011-08-01 17:06:21.520:DBUG::Search of 
file:/C:/runtime-EclipseApplication/test1/WebContent/WEB-INF/lib/wire-0.8.0.jar
2011-08-01 17:06:21.535:DBUG::skip scanning RJR jar which is already in 
WEB-INF/lib:C:\runtime-EclipseApplication\test1\WebContent\WEB-INF\lib\wire-0.8.
0.jar
2011-08-01 17:06:21.536:DBUG::scanning RJR jar for 
annotation:C:\wseclipse\run-jetty-run-jetty8\lib\servlet-api-3.0.jar
2011-08-01 17:06:21.536:DBUG::Search of 
file:/C:/wseclipse/run-jetty-run-jetty8/lib/servlet-api-3.0.jar

Original comment by tonylovejava on 1 Aug 2011 at 9:13

  • Changed title: Jetty8 servlet3 annotation support
  • Changed state: Ready

@GoogleCodeExporter
Copy link
Author

The commit is in r233 , I use some bad design this time, 
but at least it work for now , have to find a time to do a code review later. 
haha

You know, sometimes it's not very important for me to write some wonderful 
code, 
it's all about time and requirement. :P

For the additional Jetty.xml , hmm , I will try to schedule a time for it,
but I won't consider to build a default jetty.xml template , since it's 
actually required a lot of code change, and we don't have many user complain 
this so far.

If you have any user-case need any feature, 
just post a new feature and I will think about it. :P

But always , we are not concerning FREEDOM , we consider the REQUIREMENT/USE 
CASE.

Original comment by tonylovejava on 1 Aug 2011 at 9:20

  • Added labels: Type-Enhancement, fix-1.3.1
  • Removed labels: Type-Defect

@GoogleCodeExporter
Copy link
Author

btw , I will publish official 1.3.1 in two weeks if there's no any critical 
issue for the annotation .

The additional jetty.xml will be in 1.3.1 , if I could find a way to handle it 
gracefully.:)

Original comment by tonylovejava on 1 Aug 2011 at 9:23

@GoogleCodeExporter
Copy link
Author

And still a btw , we will scan all the jars which the project referenced ,
usually we assume the jars in the classpath of project is actually the jars in 
WEB-INF/lib . :)

Original comment by tonylovejava on 1 Aug 2011 at 9:25

@GoogleCodeExporter
Copy link
Author

And if the jars is already WEB-INF/lib , we will only scan it once, not twice.

Maybe there's still some bugs , please feel free to test it and let me know. 

Original comment by tonylovejava on 1 Aug 2011 at 9:26

@GoogleCodeExporter
Copy link
Author

Original comment by tonylovejava on 1 Aug 2011 at 9:35

@GoogleCodeExporter
Copy link
Author

Hi tony, thanks for this plugin.We have a use case for a jetty.xml file.
First, all our apps uses contexts different than root, but also uses flash to 
make xhr requests, and we need to have a /crossdomain.xml file, to solve this, 
we can use jetty.xml to define two contexts. The other possible sollution is to 
use a rewrite rule handler, to map a request to /crossdomain.xml to load a file 
from elsewhere. Have you any possible sollution to this without using a 
jetty.xml, or an Apache in front of Jetty? I think direct aliases may help, but 
there's no way to configure them now (also we use rewrite handler for some 
other important tasks, so it's needed too...)

Thanks!

Original comment by juan.t...@gmail.com on 23 Nov 2011 at 3:48

@GoogleCodeExporter
Copy link
Author

Hi Juan ,

For issue tracking reason , 
I moved and replied the feature request/discussion to a new issue . 

Please reference to Issue 94 and thanks for your suggestion. :) 

Original comment by tonylovejava on 23 Nov 2011 at 8:41

@GoogleCodeExporter
Copy link
Author

Thanks!
It would be very nice to have that feature!

Original comment by juan.t...@gmail.com on 24 Nov 2011 at 3:42

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant