I run the jetty-maven-plugin 8.0.0M2. Works fine after startup (mvn jetty:run) . If I change a source the plugin tries to hot deploy but gets stuck because of the following error
Duplicate fragment name: PrimeFaces for jar:file:/C:/path/to/project/webroot/WEB-INF/lib/primefaces-2.1.jar!/META-INF/web-fragment.xml and jar:file:/C:/path/to/project/webroot/WEB-INF/lib/primefaces-2.1.jar!/META-INF/web-fragment.xml
It worked fine with plugin version 7.2.0. I was upgrading because I needed el-api 2.2.
Any ideas? Thanks
Marcel
<plugin>
<groupId>org.mortbay.jetty</groupId>
<artifactId>jetty-maven-plugin</artifactId>
<configuration>
...
<webAppConfig>
...
<allowDuplicateFragmentNames>true</allowDuplicateFragmentNames>
...
</webAppConfig>
...
</configuration>
</plugin>
I think we should fight the cause instead of hiding the problem. I.e. avoid duplicate fragments. In my case fragments with the same name came from different versions of Spring, so to solve the issue I had to manage my project's dependencies properly. Analyze by the error message where are the duplicates and think whether you really need both of them or is it a dependency conflict.
If you tried Stephen Connolly's fix and you are still are having issues, you may just need to modify a your web.xml slightly to get "allowDuplicateFragmentNames" to work.
In your WEB-INF/web.xml, look for the tag (should be at the top), and modify atributes to match these values:
<web-app version="3.0" xmlns="http://java.sun.com/xml/ns/j2ee"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd"
metadata-complete="true"
..
>
<web-app version="3.0" xmlns="http://java.sun.com/xml/ns/j2ee"
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" id="WebApp_ID" metadata-complete="true">
reference : http://forum.broadleafcommerce.org/viewtopic.php?f=13&t=2145
I had a hard time getting rid of the error. My mistake was that I used two different configuration tags with the same meaning:
<webApp>...</webApp> which I had already in my configuration and then copying <webAppConfig>...</webAppConfig> from the solution above. As I finally found out, webAppConfig is an alias for webApp. After getting rid of the alias and moving all configuration into the <webApp> section the error disappeared.
It looks to me as if one uses both, then the only the content from one section is used and the other one is ignored or reset.
Related
I recently tried to convert an Eclipse, Google Appengine Project from java7-java8 since GAE has stopped supporting java7 (or will do in the near future).
The project was working fine before starting the conversion. I am now getting this error when trying to run the project locally:
java.lang.IllegalStateException: Multiple servlets map to path: /api/add-batch-shelfsurvey: ApiShelfSurveyBatchServlet,com.imobdev.figjam.ApiShelfSurveyBatchServlet
This is the entry in web.xml for that servlet:
<servlet>
<servlet-name>ApiShelfSurveyBatchServlet</servlet-name>
<servlet-class>com.imobdev.figjam.ApiShelfSurveyBatchServlet</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>ApiShelfSurveyBatchServlet</servlet-name>
<url-pattern>/api/add-batch-shelfsurvey</url-pattern>
</servlet-mapping>
This is the start of the web.xml file:
<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" version="2.5" 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_2_5.xsd">
I've double and triple checked /api/add-batch-shelfsurvey path is unique in web.xml but I still get this error.
The servlet mentioned in the error message changes but none of them have multiple mappings to one path.
I've found these threads that seem similar but aren't actually related:
https://github.com/dropwizard/dropwizard/issues/2107
https://bugs.eclipse.org/bugs/show_bug.cgi?id=479865
I don't know if it's relevant but this is my appengine-web.xml file:
<appengine-web-app xmlns="http://appengine.google.com/ns/1.0">
<threadsafe>true</threadsafe>
<url-stream-handler>urlfetch</url-stream-handler>
<system-properties>
<property name="java.util.logging.config.file" value="WEB-INF/logging.properties"/>
<property name="appengine.file.encoding" value="US-ASCII"/>
</system-properties>
<sessions-enabled>true</sessions-enabled>
<runtime>java8</runtime>
</appengine-web-app>
It is because the path
/api/add-batch-shelfsurvey
might have been registered before try to check all
<servlet-mapping>
sections in web.xml and if you have any
#WebServlet annotations then check urlPatterns={"..."}
If you have two definitions at the same time app server will not know which is the right one.
I've managed to get the project to run on the localhost and upload and run on Google App Engine. Unfortunately I don't know exactly what the problem was.
These are the steps I took:
-Removed the /* from all in web.xml file.
-Changed between version 2.5 xsd and 3.1 xsd several times, running the project on localhost each time.
-Changed back to 2.5 xsd and changed all back to ending in /*
Project then compiled and ran fine on both localhost and appengine. If anyone knows anything more about why this might happen please let me know.
When using PrimeFaces and faces-config together, I get a NullPointerException. Before adding faces-config.xml, everything worked fine. After I added faces-config.xml for changing navigation, I got the following Error when calling every page:
java.lang.NullPointerException
org.primefaces.context.PrimeFacesContext.release(PrimeFacesContext.java:26)
javax.faces.webapp.FacesServlet.service(FacesServlet.java:612)
org.primefaces.webapp.filter.FileUploadFilter.doFilter(FileUploadFilter.java:98)
de.mypackage.CharacterEncodingFilter.doFilter(CharacterEncodingFilter.java:19)
The CharacterEncodingFilter just ensures usage of UTF-8:
public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws ServletException, IOException {
request.setCharacterEncoding("UTF-8");
chain.doFilter(request, response);
}
So this can't be an error source. The faces-config.xml contains the following text:
<?xml version="1.0" encoding="UTF-8"?>
<faces-config 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-facesconfig_1_2.xsd"
version="1.2">
<navigation-rule>
<from-view-id>*</from-view-id>
<navigation-case>
<from-outcome>index</from-outcome>
<to-view-id>/index.jsf</to-view-id>
</navigation-case>
</navigation-rule>
This should direct every link to index to one index.jsf, not regarding in which folder the current site is. But if the faces-config.xml is just like this:
<?xml version="1.0" encoding="UTF-8"?>
<faces-config 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-facesconfig_1_2.xsd"
version="1.2">
the same error appears.
Everything is running on Tomcat 7.
The search for the error did not contain much results, in http://forum.primefaces.org/viewtopic.php?f=3&t=30109&start=10 someone seems to have the same problem with an old release of PrimeFaces 4.0, but as I'm getting it from maven, this can't be my error.
Has anybody an hint how to solve this problem?
The issue can be related to using JBoss Seam Mail and PrimeFaces 4.0:
http://forum.primefaces.org/viewtopic.php?f=3&t=34653
In my case, I used the PrimeFaces v3.4.2 and all worked perfectly.
After upgrade to official maven's PrimeFaces v4.0 the same NPE appears.
My faces-config.xml: <faces-config version="2.1">
Indeed, Primefaces 4 doesn't work with JSF 1.2 but it does work with JSF prior to 2.2.
From the Primefaces documentation:
PrimeFaces 4.0 supports JSF 2.0, 2.1 and 2.2 runtimes at the same time
using feature detection and by not having compile time dependency to a
specific version. As a result some features are only available
depending on the runtime.
I have seen similar questions and the answer suggested is place the JSTL jar in the classpath. I have tried both jstl.jar and jstl 1.1.jar bit My error is persistent. The Jars are coming in my web_inf/lib directory so I do not Understand what the problem is. I am using Tomcat 7
My Jsp:
<%#taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
.............
My Web.xml
<?xml version="1.0" encoding="UTF-8"?>
<web-app version="3.0" 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">
<servlet>
......
My lib Directory After Deployment:
What Should I do I am running out of Options :P
Try using jstl-1.2.1 for Tomcat7
Download JSTL 1.2.1 jar
JSTL 1.1 also requires Standard.jar.
The standard.jar (taglib) library is used to enable the JSTL expression language in JSP page, and it’s always used together with the jstl.jar together.
Download and add it to your lib folder.
Or You can use JSTL 1.2 which does not require standard.jar and also provides performance improvements.
I am trying to build a Java application that accesses data stored in Database.com using the Database.com Java SDK. I have followed the steps given at qucik start guide # http://forcedotcom.github.com/java-sdk/quick-start. When the application is deployed on tomcat server, i was getting the following exception
SEVERE: Exception sending context initialized event to listener instance of class org.springframework.web.context.ContextLoaderListener
org.springframework.beans.factory.parsing.BeanDefinitionParsingException: Configuration problem: Failed to import bean definitions from relative location [security- config.xml]
Offending resource: ServletContext resource [/WEB-INF/spring/servlet-context.xml]; nested exception is org.springframework.beans.factory.xml.XmlBeanDefinitionStoreException: Line 15 in XML document from ServletContext resource [/WEB-INF/spring/security-config.xml] is invalid; nested exception is org.xml.sax.SAXParseException: cvc-complex-type.2.4.c: The matching wildcard is strict, but no declaration can be found for element 'fss:oauth'.
at org.springframework.beans.factory.parsing.FailFastProblemReporter.error(FailFastProblemReporter.java:68)
at org.springframework.beans.factory.parsing.ReaderContext.error(ReaderContext.java:85)
at org.springframework.beans.factory.parsing.ReaderContext.error(ReaderContext.java:76)
at
Here is the security-config.xml code.
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:security="http://www.springframework.org/schema/security"
xmlns:context="http://www.springframework.org/schema/context"
xmlns:fss="http://www.salesforce.com/schema/springsecurity"
xsi:schemaLocation="http://www.springframework.org/schema/security http://www.springframework.org/schema/security/spring-security-3.0.xsd
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.0.xsd
http://www.salesforce.com/schema/springsecurity
http://media.developerforce.com/schema/force-springsecurity-1.2.xsd">
<!-- SFDC OAuth security config -->
<fss:oauth logout-from-force-dot-com="true">
<fss:connectionName name="forceDatabase"/>
</fss:oauth>
<!-- Configure Spring Security -->
<!-- use-expressions and hasRole only needed if jsp tags are used.
If not using jsp tags you can omit the use-expressions property and set access="ROLE_USER" on the intercept-url tags -->
<security:http entry-point-ref="authenticationProcessingFilterEntryPoint" use-expressions="true">
<security:anonymous />
<!-- Uncomment this section to enable security -->
<!--
<security:intercept-url pattern="/**" access="isAuthenticated()" />
-->
<!-- sets this as the authentication filter over the default -->
<security:custom-filter position="FORM_LOGIN_FILTER" ref="authenticationFilter"/>
<security:custom-filter position="LOGOUT_FILTER" ref="logoutFilter"/>
</security:http>
I can see that the element oauth is available at the xsd http://media.developerforce.com/schema/force-springsecurity-1.2.xsd. I have tried changing it to different verisons of xsd. But I was not successful.
Please help me to resolve this issue.
I am not sure if this will help, but I was experiencing some similar issue with the tag: .
This was my XML:
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:jaxws="http://cxf.apache.org/jaxws"
xmlns:context="http://www.springframework.org/schema/context"
xsi:schemaLocation="
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.0.xsd
http://cxf.apache.org/jaxws http://cxf.apache.org/schemas/jaxws.xsd">
<jaxws:endpoint id="HelloWorldService" implementor="com.client.webservices.ratecard.StandardHelloWorldService" address="/HelloWorldService" />
I tried everything without avail, until I discovered that somehow Eclipse proxy was set to direct and I was behind a proxy. Still I was able to get the first set of XSD definitions from the Apache site (http://cxf.apache.org/jaxws) nevertheless within it you can see they are importing a couple more XSD and at this point the redirection was failing and thus I was getting extremely strange errors like this.
Then I set the Eclipse proxy as Native in the preferences and the error magically disappeared.
I hope this will also work in your case.
This typically means your classpath is not setup correctly, it is not an xsd issue. To verify (if you are using Eclipse) you can right click the document and click "validate". If the xsd validates with Eclipse then you don't have to worry about that part.
What I believe happens is that Spring finds the XSD and validates but then when it encounters the fss:oauth tag it tries to find a Java class that is registered to implement the behavior for that tag and fails. Are you certain you have the Salesforce jars on your classpath?
I notice in the included schema force-springsecurity-1.2.xsd, the prefix beans is undefined. What if you modify
<beans xmlns="http://www.springframework.org/schema/beans"
to
<beans:beans xmlns:beans="http://www.springframework.org/schema/beans"
(and the last line too)?
Following Aravind A advice I simply had this dependency to my POM.
<dependency>
<groupId>org.kubek2k</groupId>
<artifactId>springockito</artifactId>
</dependency>
In fact you just need to put mockito.xsd in your path.
The problem is that the element fss:oauth should be defined in a schema (xsd file) listed at www.salesforce.com/schema/springsecurity, as defined in the declaration xmlns:fss="http://www.salesforce.com/schema/springsecurity" at the top of the page.
However the xsd file that should be in that URL it just isn't there. I guess Salesforce moved it. If you go to www.salesforce.com/schema/springsecurity you see that you get a 404 error.
I've had the same problem and I observed that the application tried to get the xsd file from the internet instead of using the jar file one. The problem was caused because a mismatch in the xsd location definition between the spring.schemas file and the location specified in the applicationContext.xml file. Changing the url from http://media.developerforce.com/schema/force-springsecurity-1.3.xsd to http://www.salesforce.com/schema/springsecurity/force-springsecurity-1.3.xsd in the applicationContext.xml file solved my problem.
I had a similar issue to this going through an integration tutorial for SFDC. In my search to resolve the issue I found this issue on the force.com github repo.
According to Github user todc
The issue, I believe, is with the media.developerforce.com URL, not the salesforce.com URL. Given the age of the repo and the lack of recent activity, I'm guessing the XSD files won't be made available again.
I was able to find archived versions of the XSD file at:
http://grepcode.com/file/repo1.maven.org/maven2/com.force.sdk/force-springsecurity/22.0.8-BETA/com/force/sdk/springsecurity/config/force-springsecurity-1.2.xsd?av=f
You can package that file into your app and refer to the local copy instead, e.g.
<beans xmlns="http://www.springframework.org/schema/beans"
xsi:schemaLocation="http://www.salesforce.com/schema/springsecurity
classpath:force-springsecurity-1.2.xsd">
</beans>
There's probably a better way, but that's what I was able to get working. Good luck!
Github user iandrosov stated
I now host this "deprecated" fiorsce-springsecurity-1.2.xsd on Heroku to give access to may apps. Sharing my public URL here so it may help others. http://force-spring.herokuapp.com/force-springsecurity-1.2.xsd
I solved this issue by using iandrosov's hosted xsd file, replacing the original
http://media.developerforce.com/schema/force-springsecurity-1.3.xsd
with his hosted xsd
http://force-spring.herokuapp.com/force-springsecurity-1.2.xsd
I've done this simply becaus I am doing a tutorial. For anybody else running into this issue it's probably better to do as Github user todc suggests and
package the file into your app and refer to the local copy instead.
Any ideas what could be the cause of this?
Unable to locate Spring
NamespaceHandler for XML schema
namespace
[http://www.springframework.org/schema/security]
org.springframework.web.context.ContextLoader initWebApplicationContext: Context initialization failed
org.springframework.beans.factory.parsing.BeanDefinitionParsingException: Configuration problem: Unable to locate Spring NamespaceHandler for XML schema namespace [http://www.springframework.org/schema/security]
Offending resource: ServletContext resource [/WEB-INF/applicationContext.xml]
This is my applicationContext.xml:
<?xml version="1.0" encoding="UTF-8"?>
<beans:beans xmlns="http://www.springframework.org/schema/security"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:beans="http://www.springframework.org/schema/beans"
xmlns:context="http://www.springframework.org/schema/context"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context-3.0.xsd
http://www.springframework.org/schema/security
http://www.springframework.org/schema/security/spring-security-3.0.xsd">
...
</beans:beans>
In my pom.xml I have:
<dependency>
<groupId>org.springframework.security</groupId>
<artifactId>spring-security-core</artifactId>
<version>3.0.1.RELEASE</version>
</dependency>
<dependency>
<groupId>org.springframework.security</groupId>
<artifactId>spring-security-openid</artifactId>
<version>3.0.1.RELEASE</version>
</dependency>
I needed to add an additional Maven dependency:
<dependency>
<groupId>org.springframework.security</groupId>
<artifactId>spring-security-config</artifactId>
<version>3.0.1.RELEASE</version>
</dependency>
I had the same error message while trying to deploy the application. In Spring, the security configuration xml can be a different one from applicationContext.xml, usually applicationContext-security.xml inside WEB-INF folder. The changes to be applied are for web.xml
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>
/WEB-INF/applicationContext.xml
/WEB-INF/applicationContext-security.xml
</param-value>
</context-param>
And the applicationContext.xml would look like:
<?xml version="1.0" encoding="UTF-8"?>
<beans:beans xmlns="http://www.springframework.org/schema/security"
xmlns:beans="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
http://www.springframework.org/schema/security http://www.springframework.org/schema/security/spring-security-3.1.xsd">
<http auto-config='true'>
<intercept-url pattern="/login.jsp" access="IS_AUTHENTICATED_ANONYMOUSLY"/>
<intercept-url pattern="/**" access="ROLE_USER" />
<form-login login-page='login.jsp'/>
</http>
</beans:beans>
Even after you make these changes, the namespace error will exist. To get rid of this, add the following jar files to the WEB-INF/lib and then to the library:
spring-security-acl-3.1.0.M2.jar
spring-security-config-3.1.0.M2.jar
spring-security-core-3.1.0.M2.jar
spring-security-taglibs-3.1.0.M2.jar
spring-security-web-3.1.0.M2.jar
I struggled with this for a while and none of these answers helped. Thanks to the comment from user64141 I realised that there was a problem with the spring.handlers files.
I am using the Shade plugin for Maven to generate a fat jar, and all the spring.handlers (and spring.schemas) files were being overwritten by each Spring dependency.
The Maven site covers this exact problem and how to solve it by appending the files together instead:
http://maven.apache.org/plugins/maven-shade-plugin/examples/resource-transformers.html#AppendingTransformer
I used spring-security-config jar it resolved the problem for me
The solution is definitely "spring-security-config" not in your WEB-INF/lib.
For my project in Eclipse using Maven, it turned out not all of the maven dependencies were being copied to WEB-INF/lib. Looking at Project -> Properties -> Deployment Assembly, only some of the jars were being copied.
To fix this, I clicked "Add", then "Java Build Path Entires" and finally "Maven Dependencies".
I have been searching SO and the web for the last hour looking for this, so hopefully this helps someone else.
A nice list of Maven Dependencies exists at : Spring Site
The major artifacts needed are:
spring-security-core
Spring-security-web
spring-security-config
#James Jithin - such exception can appear also when you have two different versions of beans and security schema in xsi:schemaLocation. It's the case in the snippet you have pasted:
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
http://www.springframework.org/schema/security
http://www.springframework.org/schema/security/spring-security-3.1.xsd"
In my case changing them both to 3.1 solved the problem
What I did:
<dependency>
<groupId>org.springframework.security</groupId>
<artifactId>spring-security-config</artifactId>
<version>3.2.5.RELEASE</version>
</dependency>
<dependency>
<groupId>org.springframework.security</groupId>
<artifactId>spring-security-web</artifactId>
<version>3.2.5.RELEASE</version>
</dependency>
and
xsi:schemaLocation="
http://www.springframework.org/schema/security
http://www.springframework.org/schema/security/spring-security-3.2.xsd
http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-4.1.xsd">
works perfectlly. More Baeldung
If you already have all dependencies in your pom, try:
1. Remove all downloaded jars form your maven repository folder for 'org->springframework'
2. Make a maven clean build.
I have encountered the very similar problem today. For some reason IntelliJ IDEA haven't included Spring Security jar files while deploying the application. I think I should agree with the majority of posters here.
I got this error while deploying to Virgo. The solution was to add this to my bundle imports:
org.springframework.transaction.config;version="[3.1,3.2)",
I noticed in the Spring jars under META-INF there is a spring.schemas and a spring.handlers section, and the class that they point to (in this case org.springframework.transaction.config.TxNamespaceHandler) must be imported.
I found this solution:
http://www.javacreed.com/unable-to-locate-spring-namespacehandler-for-xml-schema-namespace-httpwww-springframework-orgschemamvc/
Include this jar in your project
Had the same problem a few minutes ago, I was missing the 'Maven depencendies' library in my Deployment Assembly.
I added it through the section 'Web Deployment Assembly' in Eclipse
if adding dependencies haven`t solved your problem, create WAR archive again. In my case, I used obsolete WAR file without security-web and security-conf jars
Add the following dependency in your pom.xml file and if you are using IntelliJ then add the same jars to WEB-INF->lib folder.... path is Project Structure -> Atrifacts -> Select jar from Available Elements pane and double click. It will add to respective folder
<dependency>
<groupId>org.springframework.security</groupId>
<artifactId>spring-security-config</artifactId>
<version>3.0.1.RELEASE</version>
</dependency>