Cannot use JSP property group configuration with jetty-runner 9.1.4 - java

I'm trying to get a new development machine set up. I generally use jetty-runner to run my application .war file (it's a Stripes-based application).
I've got the latest version of jetty-runner (1.9.4), I think. When I try to run my .war file, I get an exception:
java.lang.IllegalStateException: No such servlet: __org.eclipse.jetty.servlet.JspPropertyGroupServlet__
I do in fact have a <jsp-config> block in my web.xml:
<jsp-config>
<jsp-property-group>
<url-pattern>*.jsp</url-pattern>
<include-prelude>/WEB-INF/fw/taglibs.jsp</include-prelude>
</jsp-property-group>
</jsp-config>
If I comment that out, then I don't get the exception. I really want that prelude because I don't want to manually include it for every file. Of course, I'm doing that the way I've always done it, where "always" is a pretty long time here.
Is there some new way of doing that stuff for including a JSP prelude, or is there something wrong with my jetty-runner, or what?
edit — I didn't make it clear that I've been using a web.xml like this, with jetty-runner (older versions), for a long time. This is happening to me with the new jetty-runner version only (I haven't tried an old one but I will).
another edit — Version 7.6.15 does not throw that exception (on the same .war file).

(from the mailing list - credit Jan Bartel)
This is a bug we introduced with a change in 9.1.4 to preserve the
order of declaration of servlets and filters. Someone else has raised
a bug for it: https://bugs.eclipse.org/bugs/show_bug.cgi?id=433365
I've committed a fix to head:
https://git.eclipse.org/c/jetty/org.eclipse.jetty.project.git/commit/?id=e2ed934978b958d6fccb28a8a5d04768f7c0432d
This fix will be backported to an upcoming 9.1.5 release.

Related

Need for web context

I need to use action="/WebConext/urlpattern" on one install of tomcat but only need to use "/urlpattern" on another install of tomcat. Why is this?
I am learning about Servlets using Eclipse and Tomcat. I have a form with action="/urlPatternOfServlet" and this worked fine for me. The url pattern was defined in servlet-mapping in web.xml.
I got a new laptop and ran the install of all environment as per previous laptop. Now I need to put the web context in the action path eg
I set up everything exactly the same and don't know why this is happening can anyone help with this.
The old laptop was running windows 8, the new machine is a VM running Windows server 2012 r2
check your web.xml in old system and make sure you have not missed web.xml with below settings
<servlet-mapping>
<servlet-name>yourserlvet</servlet-name>
<url-pattern>/WebConext/*</url-pattern>
</servlet-mapping>

Pustefix - How to move .cache folder or disable page caching?

I'm trying to build a Pustefix web application based on Pustefix' 0.16 tutorial.
Initial setup went fine, basic web app works fine.
However, simple changes made in txt/pages/main_EnterData.xml (like changing color or some text labels) have no immediate effect and nothing happens either on mvn clean tomcat:run.
The culprit is easily identified: it is folder webapp/.cache containing cached web content; here EnterData.xml.
Folder webapp/.cache is generated by Pustefix's core servlet on startup. For yet unkown reasons, that cache folder is not updated if the input source file changed.
Question 1: How to configure Pustefix to automatically update its cache?
Question 2: How to configure Pustefix to disable each and every cache?
Question 3: How to tell Pustefix where the file cache should reside?
Answer for Q1:
Define environment variable MAKE_MODE and set it to some arbitrary answer but 'prod', i.e. like
% export MAKE_MODE=devel
% mvn tomcat:run
Things changed in Pustefix 0.19:
% mvn tomcat:run -Dpustefix.mode=devel
Alternatively, use context parameter 'mode' in web.xml like
<context-param>
<param-name>mode</param-name>
<param-value>devel</param-value>
</context-param>
Answer for Q3:
Run
% mvn tomcat:run-war
in order to run the unpacked war file. When doing so, target/firstapp-myversion/.cache becomes the new cache folder.
Answer for Q2:
Impossible without breaking Pustefix internals.

Resource reference with name 'jdbc/devl' not found in ibm-web-bnd.xml

RAD 7, WebSphere 7.
ibm-web-bnd.xml:
<resource-ref name="jdbc/devl" binding-name="jdbc/devl" />
web.xml:
<resource-ref>
<res-ref-name>jdbc/devl</res-ref-name>
<res-type>javax.sql.DataSource</res-type>
<res-auth>Application</res-auth>
<res-sharing-scope>Unshareable</res-sharing-scope>
<mapped-name>jdbc/devl</mapped-name>
</resource-ref>
This conforms to the examples I see on the internet. This comes up because I am converting this app to servlet 2.5. As I understand it, the res-ref-name in web.xml should match the name attribute in resource-ref. The binding-name then matches the datasource defined in the admin console. To make it simple, I made them all match.
Is there another setting somewhere? Because this produces the error described in the title of the question.
I have the same issue many times. It disappeared when I closed the eclipse and when I reopened it I made a "project -> clean". I hope it works for the next person who has this error.
Also make sure you have the web.xml header updated to 2.5 or higher (3.0).This is related to the facets of the project, make sure they are with the same version
if it doesn't let you change it, you should change it in this file : "org.eclipse.wst.common.project.facet.core.xml"
If the error continues, you should generate the binding file again. Make sure you have the correct server settings in the facets of the project
To generate the file you must do it from java EE Tools.
Remember that ibm-web-bnd.xml and web.xml must be in the same directory
Build, and clean project.
If you are using Eclipse, try to update the web module version in project.facet.core.xml. It should be in synch with the web.xml web-app version.

Error: Wrapper cannot find servlet class VendorRegistration or a class it depends on

I'm a newb whose also been searching for a solution to the same problem. I've followed the steps that the Elite Gentleman and Bozho outlined here. So first of all, thanks a lot guys. But I still seem to have the same problem. Now as per my understanding and implementation, my situation is as follows:
My servlet class VendorRegistration is available in the folder: C:\Program Files\Apache Software Foundation\Tomcat 6.0\webapps\VendorReg\WEB-INF\classes
My web.xml is present at: C:\Program Files\Apache Software Foundation\Tomcat 6.0\webapps\VendorReg\WEB-INF\
However, I still seem to be getting the error:
****HTTP Status 500 -
type Exception report message description The server encountered an internal error () that prevented it from fulfilling this request. exception javax.servlet.ServletException: Wrapper cannot find servlet class VendorRegistration or a class it depends on****
I have also appended my web.xml file below for your consideration:
<?xml version="1.0" encoding="ISO-8859-1"?>
<web-app xmlns="http://java.sun.com/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
version="2.5">
<display-name>Welcome to Tomcat</display-name>
<description>
Welcome to Tomcat
</description>
<servlet>
<servlet-name>VendorRegistration</servlet-name>
<servlet-class>VendorRegistration</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>VendorRegistration</servlet-name>
<url-pattern>/VendorRegistration</url-pattern>
</servlet-mapping>
</web-app>
I am trying to access the servlet through the URL: http://localhost:8080/VendorReg/VendorRegistration. What am I missing ? I had compiled the .class file sometime before I installed Apache. And hence directly copied pasted the class file in the folder. Could that be a problem ?
The servlet or one of its dependencies is missing in the classpath.
First of all, always put Java classes in a package, also servlets. Packageless classes are invisible to classes in a normal package. For servlets, this works in specific environments only. You don't want to be dependent on that.
package com.example;
public class VendorRegistration extends HttpServlet {
// ...
}
With this package, the compiled .class file must end up in /WEB-INF/classes/com/example/VendorRegistration.class. Don't forget to alter the associated <servlet-class> entry in web.xml accordingly.
<servlet>
<servlet-name>VendorRegistration</servlet-name>
<servlet-class>com.example.VendorRegistration</servlet-class>
</servlet>
If that doesn't help, then you should put the classes or JAR files containing the (in)direct classes which are specified in any of the servlet's import statements also in /WEB-INF/classes (for .class files) or /WEB-INF/lib (for JAR files). The root cause in the exception stacktrace should tell which class exactly it is. Just read the stacktrace.
See also:
Servlets info page - contains a Hello World and several useful links
From tomcat 6.0 onwards, there is change in <url-pattern>
<servlet>
<servlet-name>VendorRegistration</servlet-name>
<servlet-name>VendorRegistration</servlet-name>
</servlet>
<servlet-mapping>
<servlet-name>VendorRegistration</servlet-name>
<url-pattern>/servlets/servlet/VendorRegistration</url-pattern>
</servlet-mapping>
It worked in my case!
In my case the problem started when I made a copy/paste of HelloWorld.java class example from another project. Finally I solved it out by simply creating a new package, then a new HelloWorld.java from scratch and copy just the code for the doGet() method.
Then I restarted the server and ran http://localhost:8080/mltest/HelloWorld
And it worked!
I faced the same problem too. Actually one of my program which was working already after few changes showed me this error. I even did undo to revert the changes, still It happened to me.
Finally I found a working solution for this for my scenario.
SIMPLE:
1.Just try to clean your project and run again. If it shows the same error and if you are sure there isn't any problem with your code then,
2.Enable the "Build Automatically" menu item under "Project" menu and try to clean your project. This time it worked for me.
Heard this is because when we make some changes and run, eclipse does some changes in its background too. So even if we revert the changes, eclipse might have not reverted the changes which it did in background. So performing these 2 steps will make sure it matches with the user change with its background change.
Hope it helps and solves your problem too.
This is how I solved the problem when I had the same exception with yours.
Ensure you add the right libraries, we need to add the Library Tomcat. At the beginning, I just added the servlet-api.jar, but someone told me it's not a right way. Maybe when you implemented the project in tomcat it had some Conflicts with Tomcat.
Ensure your project in the right folder, %Tomcat_HOME%\webapps\%projectName\WEB-INF\classes\.....
Ensure web.xml in the right folder, and with right form,
%Tomcat_HOME%\webapps\%projectName\WEB-INF\web.xml
Reload the application in Tomcat.
Access the servlet through URL:
http://localhost:port/%projectName%
I'm afraid you made a mistake to try to access a servlet class directly.
Generally, the URL should be your any txt, jsp, html files under your application folder , but the servlet is used for response your "POST" or "Get" request from client side, it's immpossible to access it directly through URL.

Servlet exception in java

I imported a java project(war file) to eclipse. When I tried to run it , I got following error :
java.lang.Error: Unresolved compilation problems:
The type List is not generic; it cannot be parameterized with arguments <User>
Syntax error, parameterized types are only available if source level is 5.0
I tried to google it. I found that I have to change compliance settings. I changed the compiler compliance level to 5 but it did not solve the problem. Can anybody help me to solve this problem? Thanks in advance.
There are two things you might have to take care of.
The compiler setting.
The runtime setting.
I guess you should have taken care of (1). What you may have missed is the second one. When you try to run that war file, go to "Run As" --> "Run configurations". There you can select the Java version. I assume this is the place you are having an issue. Try setting it to Java 1.5 or higher.
http://img638.imageshack.us/img638/8845/runconfig.jpg
Check java version for your servlet container. You can check Java version in shell by typing
java -version
If its not 1.5+ point to relevant JDK of higher version..
That war is using 'generics' somewhere. and generics is only available with java 5 and above thats the error is saying
please check your java compiler level
The first step to resolving this issue, is to completely ignore the hint "-source 1.5 to enable generics". That message will take you nowhere! The reason being that it originates from the javac compiler, while you need to configure the jasper JSP compiler. This is fortunately quite easy, although finding out on the Tomcat site is quite convoluted. All you need to do is to edit your TOMCAT_INSTALL\conf\web.xml. Add to the org.apache.jasper.servlet.JspServlet the following lines
<init-param>
<param-name>compilerSourceVM</param-name>
<param-value>1.5</param-value>
</init-param>
<init-param>
<param-name>compilerTargetVM</param-name>
<param-value>1.5</param-value>
</init-param>
such that the servlet looks something like the following
[web.xml]
<servlet>
<servlet-name>jsp</servlet-name>
<servlet-class>org.apache.jasper.servlet.JspServlet</servlet-class>
<init-param>
<param-name>fork</param-name>
<param-value>false</param-value>
</init-param>
<init-param>
<param-name>xpoweredBy</param-name>
<param-value>false</param-value>
</init-param>
<init-param>
<param-name>compilerSourceVM</param-name>
<param-value>1.5</param-value>
</init-param>
<init-param>
<param-name>compilerTargetVM</param-name>
<param-value>1.5</param-value>
</init-param>
<load-on-startup>3</load-on-startup>
</servlet>
You have now configured your Tomcat JSP server...
Configuring Eclipse
The EE edition of Eclipse has a nice feature of enabling you to create a Dynamic web project - essentially an exploded war file and manage the server instance for you and set up debugging. Convenient once you know how it works. Basically what the standard setup does, is that it copies the Tomcat configuration files from your install directory onto some obscure path similar to c:\workspace.metadata.plugins\org.eclipse.wst.server.core\tmp0\conf\ The first thing to realize is that it copies the files from your installed Tomcat directory quite frequently, so editing your web.xml in this directory as instructed above will only work for a short time.
You may also try editing the web.xml under the Servers project Eclipse installs when you setup your first server. I had a very hard time making Eclipse pick up changes in this file..
Instead, simply delete your server instance and re-create it. Your changes will now have been picked up and you are ready to go!

Categories