I creating a web project using maven, java 7, String framework, hibernate, JPA and restful service in Eclipse. I changed the jre library in Java Build Path and also change the compiler.
but now i got error
Cannot change version of project facet Dynamic Web Module to 3.0.
thanks in advance !!!
The solution given by #enkor may work for you (Question is the same):
Cannot change version of project facet Dynamic Web Module to 3.0?
you need to change the version into web.xml you need change some configuration you can find it below:
<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_3_0.xsd"
version="3.0">
<display-name>Servlet 3.0 Web Application</display-name>
</web-app>
then Update Project.
Related
im learning SpringMVC, and find this problem, project running well, but this is irritating
I think the web.xml is in wrong place
<web-app>
<display-name>Archetype Created Web Application</display-name>
</web-app>
this line in web.xml is giving error.
you just have to delete these lines from the file "web.xml"
<web-app>
<display-name>Archetype Created Web Application</display-name>
</web-app>
Working on sample spring boot application using spring-boot-starter-parent 2.0.5 with security. Main spring boot application class extends SpringBootServletInitializer. War file generated and works fine in tomcat. I deployed same war file on websphere application server and the application starts but it looks like spring boot is not getting initialized. I don't see any error in log. Is thre anything should be done for the application to initialize in websphere?
The issue is resolved by updating web.xml from
<!DOCTYPE web-app PUBLIC
"-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN"
"http://java.sun.com/dtd/web-app_2_3.dtd" >
<web-app>
<display-name>Archetype Created Web Application</display-name>
</web-app>
to latest format
<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="http://xmlns.jcp.org/xml/ns/javaee"
xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/web-app_3_1.xsc"
id="webApp_ID" version="3.1">
<display-name>Archetype Created Web Application</display-name>
</web-app>
I have a webapp with Maven which uses Tomcat plugin for the server. The app gets compiled to .war which, when extracted, seems to contain all classes (incl. servlets) in WEB-INF/classes folder.
When the url http://localhost:8080/com.galya.crm gets hit, index.html (which is a SPA app) gets loaded normally redirecting to http://localhost:8080/com.galya.crm/#!/login/msg/notlogged
I have 4 servlets annotated in a similar manner:
#WebServlet("/restapi/login")
public class LoginController extends HttpServlet {
The problem comes when the SPA app tries to authenticate using the login servlet (shown above). I expect it to be here: http://localhost:8080/com.galya.crm/restapi/login , but I get 404 error.
Below I attached the Tomcat plugin folder that is automatically created. Work directory is empty and I'm not sure if it's OK.
Initially the webapp/WEB-INF/web.xml was auto generated and contained the following:
<!DOCTYPE web-app PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN" "http://java.sun.com/dtd/web-app_2_3.dtd" >
<web-app>
<display-name>Archetype Created Web Application</display-name>
</web-app>
I also tried to change it to accept WebServlet annotations, but didn't work also:
<!DOCTYPE web-app PUBLIC
"-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN"
"http://java.sun.com/dtd/web-app_2_3.dtd" >
<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_3_0.xsd"
version="3.0">
</web-app>
P.S. The app was working on another server some time ago, so the problem should be in the server configurations, not in the code itself.
Surely the cause is that the deployment descriptor must be declared to be of version 3.0. Your web.xml is still 2.3.
Remove the DOCTYPE declaration and leave the root node just as you already did:
<web-app
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="http://java.sun.com/xml/ns/javaee"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd"
version="3.0">
Tested myself, and it worked.
I've been struggling for 2-3 weeks now with transforming my project (single module) into a multi module project where the modules are representing the layers of a multilayer architecture (i.e. persistence, business, domain...)
When the project was still a single module, everything worked together. I had my ManagedBean classes managed by JSF and enabled #Autowired for Spring with a workaround, so I could inject my Spring-managed classes into the jsf-managed beans. Now, this won't seem to work anymore, so I'm trying to clean my code up and orientate myself at some examples I've seen (one is the Maven archetype for jsf2 + spring 4 integration).
It seems, there are two ways suggested to do the Dependency Injection:
Do it per #ManagedProperty (But I don't want to do this all per JSF)
Do it per #Autowired and let Spring manage the Backing/Managed Beans (That's what I try to do)
Though many sources (even the Maven archetype, which is working) suggest to just annotate my Backing Bean class with Spring annotations (#Component, #Scope("session")), I always get the error
Caused by: javax.el.PropertyNotFoundException: Target Unreachable, identifier 'administration' resolved to null
web.xml
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>
classpath*:/WEB-INF/applicationContext.xml
</param-value>
</context-param>
<listener>
<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>
<listener>
<listener-class>
org.springframework.web.context.request.RequestContextListener
</listener-class>
</listener>
applicationContext.xml
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:tx="http://www.springframework.org/schema/tx"
xmlns:context="http://www.springframework.org/schema/context"
xsi:schemaLocation="
http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-4.0.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context-4.0.xsd
http://www.springframework.org/schema/tx
http://www.springframework.org/schema/tx/spring-tx-4.0.xsd" >
<context:component-scan
base-package="my.base.projectpackage" />
<context:annotation-config />
<context:spring-configured />
<!-- import the other context files for Spring -->
<import resource="classpath*:META-INF/*-springContext.xml"/>
faces-config.xml
<faces-config xmlns="http://xmlns.jcp.org/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee
http://xmlns.jcp.org/xml/ns/javaee/web-facesconfig_2_2.xsd"
version="2.2" metadata-complete="false">
<application>
<el-resolver>org.springframework.web.jsf.el.SpringBeanFacesELResolver</el-resolver>
</application>
</faces-config>
I've already tried to:
Enable Autowiring into a JSF managed bean (per [...].autowire(this) -> not working, NPE for the Service class)
Try it with #ManagedProperty on JSF annotated Service classes (not working, NPE for the Service class)
Try it with pure Spring classes (like mentioned above, not working identifier resolved to null for the managed bean)
I can compile and build the modules and the whole project without errors, and I've also not forgotten to put intermodular dependencies (like business module is depending on persistence module) into the pom.xml. Every module has packaging "jar" (except ofc the webapp module, which is war). Did I forget to mention something else?
I run the project on Tomcat 8 (though this should not be the source of the error).
Maybe someone of you has got a hint, idea or solution for me.
Thanks in advance.
Edit
I got my project to work again and split it into multiple modules. But the only way to do this was to really copy + paste (argh! really..) my classes into the Maven archetype project and add some minor, not important fixes (like cleaning out my POM files). When it worked there, I was curious, copied the project files back into my old project and tried it there again. Surprisingly, it still didn't work, even though there was no difference anymore which could have caused it not to work. So, the mystery is still unsolved, but after all, I could continue with my work.
Thank you for your help (or for trying to help me, since this was a lost cause) #Tiny.
Is there a way to pass a variable into a method param:
<h:commandButton value="Add to Order"
actionListener="#{orderBasket.addItems(currentItem.id)}"/>
This always seems to pass 0 into the method for some reason.
That's only possible when you use action instead of actionListener
<h:commandButton value="Add to Order"
action="#{orderBasket.addItems(currentItem.id)}"/>
and you're running a Servlet 3.0 / EL 2.2 capable container (Tomcat 7, Glassfish 3, JBoss 6, etc) and your web.xml is declared conform Servlet 3.0 spec with the following root declaration
<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_3_0.xsd"
version="3.0">
If the latter two are not true for your case (e.g. you're using Servlet 2.5), then you need to replace the EL implementation by another one which supports that, such as JBoss EL. For detail, see this answer.