I m trying to debug some jsp pages in eclipse. These pages depends on some other projects, that are located in workspace. The physical files are located in webapps directory. I'm using tomcat7 as server. I have started Tomcat with standard configuration(debug at port 8000) and left also port 8000 in remote debug configuration. In my workspace there is a ic-config with WEB-INF and web.xml. It maps com.quartal.irtoolbox.ic.ControllerServlet to Controller like the following:
<servlet>
<servlet-name>Controller</servlet-name>
<servlet-class>com.quartal.irtoolbox.ic.ControllerServlet</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>Controller</servlet-name>
<url-pattern>/Controller</url-pattern>
</servlet-mapping>
But when i try to access Controller , it is not accessible at all.I'm getting the error: "The requested resource (/Controller) is not available". What should i change and how should i call the servlet to be able to get and debug it?
Thanks
Magda
Related
I am using tomcat7 and have a small Java application that needs to be deployed under ROOT. The reason for this has to do with the client's inability to specify the webapp's proper context path at this time.
I have an index.html in this webapp and my issue is that when I deploy the application under the webapp name - ${catalina_home}/mywebapp - the index.html renders without a problem when I navigate to http://localhost:8080/mywebapp.
However, when I deploy it under ROOT - ${catalina_home}/ROOT - the index.html inside does not render when I navigate to http://localhost:8080/. The error is 404 not found. Does this have anything to do with overriding tomcat's default page?
My web.xml:
<context-param>
<param-name>resteasy.servlet.mapping.prefix</param-name>
<param-value>/</param-value>
</context-param>
...
<servlet-mapping>
<servlet-name>resteasy-servlet</servlet-name>
<url-pattern>/*</url-pattern>
</servlet-mapping>
...
Can someone explain why this is so?
Thanks in advance.
UPDATE: I see in this stackoverflow Display html page in tomcat from maven RESTEasy webapp that the issue may be that my filter says anything under /* should go to the servlet. I tried to set up a default servlet for .html pages, but that does not see to help yet...
<servlet>
<servlet-name>default</servlet-name>
<servlet-class>org.apache.catalina.servlets.DefaultServlet</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>default</servlet-name>
<url-pattern>*.html</url-pattern>
</servlet-mapping>
How do you deploy the app as ROOT? If you package as war file, to deploy as ROOT, change the war file to ROOT.war and have the index.html under the ROOT folder. Also check the web.xml under WEB-INF to have the welcom page set to index.html as below:
<welcome-file-list>
<welcome-file>
index.html
</welcome-file>
</welcome-file-list>
I found the answer here - http://docs.jboss.org/resteasy/docs/3.0.2.Final/userguide/html_single/:
"The downside of running Resteasy as a Servlet is that you cannot have static resources like .html and .jpeg files in the same path as your JAX-RS services. Resteasy allows you to run as a Filter instead. If a JAX-RS resource is not found under the URL requested, Resteasy will delegate back to the base servlet container to resolve URLs."
I created a filter instead and I was able to serve both the static page and my regular REST resources.
I have an mp4 video on my GlassFish java application server. What URL do I use to access it in a browser?
The video path in the application on the server is:
myapp/WEB-INF/videos/myvideo.mp4
I tried adding this to my web.xml file:
<servlet>
<servlet-name>myvideo</servlet-name>
<servlet-class>videos.myvideo.mp4</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>myvideo</servlet-name>
<url-pattern>/myvideo</url-pattern>
</servlet-mapping>
and restart the server, then go to the URL: https://www.example.com/myapp/myvideo but that just gave this error:
java.lang.ClassNotFoundException: videos.myvideo.mp4
Obviously it's not a servlet, but not sure what else to try.
Why are you trying to access the video as a servlet and not as a static asset, like you would an image? Using a servlet mapping is obviously wrong.
Instead if you have a running WebApp in GlassFish you should be able to access it via https://www.example.com/myapp/videos/myvideo.mp4 assuming you've put the videos folder under your webapp's j2ee root.
The j2ee root would be configured in your application.xml as the web-uri. In your case it is likely that the myapp folder is your j2ee root. So move your videos up a folder.
(Converted comment 'discussion' into an answer).
I'm packaging a web application and tomcat into a zip file. This zip should be able to use in any location or path.
This web application require to load an additional folder (response-folder) to be able to startup.
Due to the zip can be unzip anywhere, I need to find out my current path when the server is started and set the path in the startup.bat.
The following is my zip folder structure:
my.zip
- apache-tomcat
- bin
- startup.bat
- webapp
- mywebapp
- WEB-INF
- web.xml
- response-folder
In my startup.bat, I had the following line
set CATALINA_OPTS=-Dapache-tomcat-current-folder="%TOMCAT_CURRENT_FOLDER%"
I would like achieve something like below:
<servlet>
<description>MyService</description>
<display-name>MyService</display-name>
<servlet-name>MyService</servlet-name>
<servlet-class>com.my.package.MyService</servlet-class>
<init-param>
<description>Folder that contains response files</description>
<param-name>RESPONSE_FOLDER</param-name>
<param-value>${apache-tomcat-current-folder}\response-folder</param-value>
</init-param>
<load-on-startup>1</load-on-startup>
</servlet>
Note: I'm not able to the change the web application java code, as the web application is not belong to me.
May I know is there anyway to make web.xml to support variable interpolation or achieve behavior such as above?
Any help would be great.
To use environment variables in web.xml, you can add
set "CATALINA_OPTS=-Dapache-tomcat-current-folder=somevalue"
or if you want to reference a System environment variable
set "CATALINA_OPTS=-Dapache-tomcat-current-folder=%apache-tomcat-current-folder%"
in bin/setenv.bat (bin/setenv.sh for *nix).
You need to create this file.
I deployed war file with some static resource (.zip) on glassfish server # physical location {WebAppRoot}/resources/WebFiles/zippedFiles/{FileName}.zip so for downloading/accessing file from browser relative path or URI will be {domain.com}/resources/WebFiles/zippedFiles/{FileName}.zip.Someday before i am trying to enable resume support for downloading such files after some Googleing i come to know that i have to tell glassfish that .zip file is an static content,so after adding
<servlet-mapping>
<servlet-name>DefaultServlet</servlet-name>
<url-pattern>.zip</url-pattern>
</servlet-mapping>
Resume support is enabled.
So my question is,Before adding <servlet-mapping> how the .zip file is served? Is that file handled by DispatcherServlet (Dynamic content)? How the server knows URI({domain.com}/resources/WebFiles/zippedFiles/{FileName}.zip) is of an file not the controller or JSP (view) for which DispatcherServlet is resposible.
And one last what is benefit of adding such <servlet-mapping>?
There is a 'default servlet' that handles all unmapped resources.
I've created a .jar with some Jersey web services in it, and I want to import that .jar in other projects. Those web services work like a handler/proxy for local code to link with a remote service provider.
So, I import the .jar document in a project and configure web.xml like this:
<servlet>
<servlet-name>Services</servlet-name>
<servlet-class>com.sun.jersey.spi.container.servlet.ServletContainer</servlet-class>
<init-param>
<param-name>com.sun.jersey.config.property.packages</param-name>
<param-value>com.package.for.services.in.current.project, com.package.for.services.in.jar</param-value>
</init-param>
</servlet>
<servlet-mapping>
<servlet-name>Services</servlet-name>
<url-pattern>/s/*</url-pattern>
</servlet-mapping>
But when I run the project, the web services specified in com.package.for.services.in.jar aren't found.
The .jar document is in build path. What am I doing wrong? Isn't possible to run web services from an external library?
Thanks in advance.
I found the answer from this post: Jersey REST The ResourceConfig instance does not contain any root resource classes
The PackagesResourceConfig class depends on having a directory with the name of the package in order to find the classes within it. I went back to Eclipse, and found an option at the bottom of the "Export ... > Jar" dialog for "Add directory entries." I turned that on, exported the jar again, and then the scanning found my resource classes. You'll need to find some comparable option in your build environment.