• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Error deploying simple servlet

 
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi all,
I have just installed jboss 5.1.0.GA and set it as a server in eclipse (in which I also installed the jboss tools). I made a new web project and wrote a simple servlet, only to see if it is all ok, but the response of jboos when I called my servlet was an exception report:

javax.servlet.ServletException: non-HTTP request or response
javax.servlet.http.HttpServlet.service(HttpServlet.java:845)
org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFilter.java:96)


The code of my servlet is:




The web.xml is:



What could be the problem?

Another little question: in eclipse do I have to re-export the project as a war file and put it in deploy dir ALL THE TIME? Is there a faster method to test the web app?

Thanks
 
author
Posts: 5856
7
Android Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hmm, works for me, but then I am not using Eclipse and I did not use your exact code, instead I modified an existing servlet to follow the same pattern as yours (not HTML tags in the output, no code for doPost).

When you created the server in Eclipse, what configuration (default? all? web?) did you choose?

in eclipse do I have to re-export the project as a war file and put it in deploy dir ALL THE TIME?



This sounds like you are using Eclipse to create a WAR file and then using the file manager to copy the WAR file - is that what you are doing? If my guess is correct, what are the exact contents of the WAR file? You can find that out using "jar -tf xxx.war". You should add the web app project to the server and then you should be able to do a resynch within Eclipse. The JBoss Tools docs have a turorial that shows all of the steps to do this.

 
Andy Peer
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I use the default configuration.

I tried to add my project to the server but it returns a Java.Lang.NullPointerException!! So i exported the war (via eclipse) to the deploy directory manually.
I am on winXP and jar -tf command does not work.

The app seems to be well exported, *.html files work, but neither servlet nor *.jsp work, it's very strange.
I have to say, I created the project as a normal web project; in eclipse (in jboss tools) i only found jsf project and struts project, not j2ee project.
Then, when I created the servlet, I got an error sayng "javax.servlet cannot resolve class" so I added manually, as an external jar, the javaee.jar into my project.
Perhaps this could be the problem? Does jboss want I use its own *.jar files?
 
Peter Johnson
author
Posts: 5856
7
Android Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

I am on winXP and jar -tf command does not work.



Is %JAVA_HOME%\bin in your PATH? Oh, and I hope that you have a JDK, and not just a JRE.

I tried to add my project to the server but it returns a Java.Lang.NullPointerException!!



That does not sound good - every time I get something like this in Eclipse the only way I have been able to fix it is to reinstall Eclipse and the plugins I use (I am down to three plugins). By the way, which JBoss Tools plugin URL did you use? I hope it was not for the nightly builds - those can be fairly buggy. Use either the stable released or stable development versions. And make sure that the JBoss Tools you install are for the correct version of Eclipse. So, which version of Eclipse and which version of JBoss Tools are you using?

I created the project as a normal web project



When dealing with matters digital, precision is a requirement. When I look at the list of projects Eclipse can create I see one labeled "Dynamic Web Project" and another labeled "Static Web Project". I do not see one labeled "normal web project" or even simply "web project". Therefore, I have no idea what type of project you created.
 
Peter Johnson
author
Posts: 5856
7
Android Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I now have your exact servlet, and entering in the URL http://localhost:8080/hello/MiaServlet I get the output "Hello". I am using Eclipse 3.5 with JBoss Tools 3.1 and JBoss AS 5.1.0.GA with the 'default' configuration. Also, JDK 1.6.0_14 64-bit.

Do you have a stray servlet.jar file somewhere, like in your WAR file? I ask because when I went to the sources and looked at HTTPServet.java, there is no line 845, as reported by the stack trace (it has only 811 lines).
 
Andy Peer
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The %JAVA_HOME%/bin was not set, now it is set correctly.
I had a older version of eclipse, I downloaded the 3.5 and than installed the JBoss tools 3.1 development, now when I export it works!

The project I made was a "Dynamic web project", don't you think it is strange I had to add manually (as external jar) the javaee.jar?

Another little question: now I can add the project to the server and I have no errors, but when I run my servlet (Run as --> run on server) I have a 404 not found error. It seems that eclipse does not export it. Do I have to set up the server as a debug server to "hot" test my application (without always export war) ?

Btw thanks a lot for your help
 
Peter Johnson
author
Posts: 5856
7
Android Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

don't you think it is strange I had to add manually (as external jar) the javaee.jar?



I noticed that too - for some reason the required JAR files based on the facets of the project are not being supplied for the project. This seems to be an issue with Eclipse 3.5 + JBoss Tools 3.1 - not sure whose issue it is. This worked fine on Eclipse 3.4.2 with JBoss Tools 3.0.

but when I run my servlet (Run as --> run on server) I have a 404 not found error



What URL is Eclipse generating? I have found that at times the URL is incorrect and I have to fix it.

Also, since you posted this same question on the JBoss Forums, could to reply there stating what the solution was to the problem for the benefit of the readers of that forum? Thank you.
 
Andy Peer
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Eclipse generate http://localhost:8080/test/MiaServlet
I think because the project is never exported or copied or builded under jboss, so for jboss it doesn't exist!
Could it be a problem of JBoss Tool 3.1 development? (they are not completly stable).
With eclipse 3.4.2 and jboss tools 3.0 everything work fine?

PS: Sorry for the double posting, I thought it was a "new issue" so I created a new thread. I also posted the solution on the jboss community forum
 
Peter Johnson
author
Posts: 5856
7
Android Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
It's working for me (Eclipse 3.5 + Tools 3.1 stable dev build)

I think because the project is never exported or copied or builded under jboss, so for jboss it doesn't exist!



Did you turn off auto-build in Eclipse? (Preferences, under General | Workspace) If so, you will have to manually build (right-click project in Project Explorer, select Build form the menu), and then I think you also have to manually synchronize (right-click server in Server View, select Synchronize from the menu). If you leave Automatically Build on, then you don't have to do this.

In the Server View, is the status of the app server "Started, Synchronized"?

In the Console View, do you see the web app being deployed just after the "started in xxx seconds" message:

09:39:51,043 INFO [ServerImpl] JBoss (Microcontainer) [5.1.0.GA (build: SVNTag=JBoss_5_1_0_GA date=200905221634)] Started in 54s:977ms
09:39:54,116 INFO [TomcatDeployment] deploy, ctxPath=/test
 
Andy Peer
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Yes, everything is configured correctly.
The only thing I don't see is [TomcatDeployment] deploy, ctxPath=/test
Also when I click build it seems nothing to happen.

Could you tell me step by step how you set up your eclipse/jboss/jboosTools configuration? I'm going crazy!
 
Peter Johnson
author
Posts: 5856
7
Android Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

The only thing I don't see is [TomcatDeployment] deploy, ctxPath=/test


Sounds like you did not add the project to the app server. In the Server View, right-click on the server and select Add And Remove. If the "test" project is listed under Available, select it and click the Add> button - the project should then appear under Configured.

Also when I click build it seems nothing to happen.



Does this file exist within your project: build/classes/coreservlets/MiaServlet.class
You will have to use a file manager to browse for this - you will not see it in Eclipse.
 
Andy Peer
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I have already added the project to the server, but nothing happens when i click build.


Does this file exist within your project: build/classes/coreservlets/MiaServlet.class
You will have to use a file manager to browse for this - you will not see it in Eclipse.


Yes, that file exist.

Don't I have to change the build path of the project to the directory of jboss?
Are you sure it is sufficient to click build to deploy the project within the server?
I really don't know what I do wrong!
 
Peter Johnson
author
Posts: 5856
7
Android Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The steps I followed were:

1) Created a new server. Used 'JBoss Community | JBoss AS 5.1'. Did not add any projects at that time. Once the server was created, started it and then stopped it (just to verify that it was set up correctly.)

2) Create a "Dynamic Web Project", added the server-api.jar file to the project libraries (Eclipse 3.5 only, in 3.4.2 it was there automagically).

3) Created a servlet, used your code as-is.

4) Added the project to the server, started the server.

That's it.

Another file to look for. From your workspace directory, look up .metadata/.plugins/org.jboss.ide.eclipse.as.core/JBoss_5.1_Runtime_Server/deploy. The "JBoss_5.1_Runtime_Server" might be different based on what you named your server. This directory should include an explode test.war directory (assume a project named 'test') and that should have WEB-INF/classes/coreservlets/MiaServlet.class and WEB-INF/web.xml.
 
Peter Johnson
author
Posts: 5856
7
Android Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
More questions. In the Server View, if you expand the server, does the 'test' project show up? Is it's status 'Synchronized'? If not, then right-click the server, and click Publish, and see if the status changes to Synchronized.
 
Andy Peer
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I solved it!
All thos files are ok, I noticed that in the server configuration overview, in the deployment section, it was selected "Use workspace metadata"; I selected insted "Use the JBoss deploy folder" and it works.

But there is another little problem...
I learned that when I modify an html or jsp page, those modifies are available immeditially; but any modify to java code must be followed by a re-deploy.
In the JBoss forum they tell me I have to click the "Touch descriptor" button, but nothing happes, it does not re-deploy, do you know how to re-deploy?
 
Peter Johnson
author
Posts: 5856
7
Android Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I use "Use workspace metadata" and it works for me (hence the file I asked to to look for in .metadata).

I've seen some forum discussion about "Touch descriptor" and it not working at times. I don't know what the resolution was. As a workaround, you can always open WEB-INF/web.xml, make an innocuous change (and an remove a space), and save it again. The file will be recopied and the app server will notice the updated timestamp and deploy the app.
 
Andy Peer
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Yeah, it works only sometimes, I have to modify web.xml by myself.

Thank you Peter for you help, you have been very kind!
 
reply
    Bookmark Topic Watch Topic
  • New Topic