wood burning stoves 2.0*
The moose likes Other Application Frameworks and the fly likes OSGI: problem in registerResources , 404 error Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of OCA/OCP Java SE 7 Programmer I & II Study Guide this week in the OCPJP forum!
JavaRanch » Java Forums » Frameworks » Other Application Frameworks
Bookmark "OSGI: problem in registerResources , 404 error" Watch "OSGI: problem in registerResources , 404 error" New topic
Author

OSGI: problem in registerResources , 404 error

avseq anthoy
Ranch Hand

Joined: Apr 27, 2004
Posts: 104
Dear all

I am studying OSGI recently.

I have some problem in the sample code.

My source file as below:
src
- org/riawork/demo/user/validator
- org/riawork/demo/web/servlet/LoginServlet
- page/login.htm

I register the page in the the Activator.


But when I input the url "http://localhost/demo/page/login.htm" in IE.
The HTTP 404 occur.
Are there any wrong in my sample code?
My Activator soucre code as below


Best Regards


My Way,My Pace
Lester Burnham
Rancher

Joined: Oct 14, 2008
Posts: 1337
Is "demo" the name of the web app of which this code is a part? If so, I'd guess that any URLs need to be of the form "/login" instead "/demo/login".
avseq anthoy
Ranch Hand

Joined: Apr 27, 2004
Posts: 104
Thanks for your reply.
I didn't create Web Project in eclipse. I only create a normal java project.
And the register the path use the OSGI HttpService.
Lester Burnham wrote:Is "demo" the name of the web app of which this code is a part? If so, I'd guess that any URLs need to be of the form "/login" instead "/demo/login".
Lester Burnham
Rancher

Joined: Oct 14, 2008
Posts: 1337
Are you certain that the HttpService runs on port 80 of localhost at the root level?

Have you gotten an unaltered example of HttpService to run?
avseq anthoy
Ranch Hand

Joined: Apr 27, 2004
Posts: 104
Yes , I am sure that HttpService runs on port 80.
If I stop the osgi , the IE shows "can't find server".
But if I start the osgi , the IE shows

HTTP ERROR 404
Problem accessing /demo/page/login.htm. Reason:

ProxyServlet: /demo/page/login.htm


Lester Burnham wrote:Are you certain that the HttpService runs on port 80 of localhost at the root level?

Have you gotten an unaltered example of HttpService to run?
Lester Burnham
Rancher

Joined: Oct 14, 2008
Posts: 1337
A quick search for registerResources examples indicates that the 2nd parameter is an absolute directory path. Which would make the relative path you're using problematic (as relative paths always are in web apps). Which brings us back to:
Lester Burnham wrote:Have you gotten an unaltered example of HttpService that uses registerResources to run?
avseq anthoy
Ranch Hand

Joined: Apr 27, 2004
Posts: 104
My source code is similar to the original sample code except the import statemensts.
And the file location structure are same.
Because the sample code has some chinese word thant only print some text, so I delete it.
It should not influence overall work.
Original sample code as below.
Lester Burnham
Rancher

Joined: Oct 14, 2008
Posts: 1337
And did you get that code to run OK?
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: OSGI: problem in registerResources , 404 error