0

I'm currently working with eclipse (jdk/jre 1.7 ) and i'm using logical and operator in a javascript function :

 if (obj1.line && obj1.from && obj1.to) {
                line = obj1;
                obj1 = line.from;
                obj2 = line.to;
            }

when i'm deploying my project i have this error :

    ERROR [org.apache.catalina.core.ContainerBase.[jboss.web].[default-host].[/PFE-PresentationLayer].[Faces Servlet]] (http-localhost-127.0.0.1-8080-5) "Servlet.service()" pour la servlet Faces Servlet a généré une exception: javax.faces.view.facelets.FaceletException: Error Parsing /ancien.xhtml: Error Traced[line: 94] The entity name must immediately follow the '&' in the entity reference.
at com.sun.faces.facelets.compiler.SAXCompiler.doCompile(SAXCompiler.java:426) [jsf-impl-2.1.3-b02-jbossorg-2.jar:2.1.3-SNAPSHOT]
at com.sun.faces.facelets.compiler.SAXCompiler.doMetadataCompile(SAXCompiler.java:409) [jsf-impl-2.1.3-b02-jbossorg-2.jar:2.1.3-SNAPSHOT]
at com.sun.faces.facelets.compiler.Compiler.metadataCompile(Compiler.java:130) [jsf-impl-2.1.3-b02-jbossorg-2.jar:2.1.3-SNAPSHOT]
at com.sun.faces.facelets.impl.DefaultFaceletFactory.createMetadataFacelet(DefaultFaceletFactory.java:327) [jsf-impl-2.1.3-b02-jbossorg-2.jar:2.1.3-SNAPSHOT]
at com.sun.faces.facelets.impl.DefaultFaceletFactory.access$200(DefaultFaceletFactory.java:93) [jsf-impl-2.1.3-b02-jbossorg-2.jar:2.1.3-SNAPSHOT]
at com.sun.faces.facelets.impl.DefaultFaceletFactory$2.newInstance(DefaultFaceletFactory.java:166) [jsf-impl-2.1.3-b02-jbossorg-2.jar:2.1.3-SNAPSHOT]
at com.sun.faces.facelets.impl.DefaultFaceletFactory$2.newInstance(DefaultFaceletFactory.java:164) [jsf-impl-2.1.3-b02-jbossorg-2.jar:2.1.3-SNAPSHOT]
at com.sun.faces.facelets.impl.DefaultFaceletCache$2.newInstance(DefaultFaceletCache.java:94) [jsf-impl-2.1.3-b02-jbossorg-2.jar:2.1.3-SNAPSHOT]
at com.sun.faces.facelets.impl.DefaultFaceletCache$2.newInstance(DefaultFaceletCache.java:89) [jsf-impl-2.1.3-b02-jbossorg-2.jar:2.1.3-SNAPSHOT]
at com.sun.faces.util.ExpiringConcurrentCache$1.call(ExpiringConcurrentCache.java:99) [jsf-impl-2.1.3-b02-jbossorg-2.jar:2.1.3-SNAPSHOT]
at java.util.concurrent.FutureTask$Sync.innerRun(Unknown Source) [:1.7.0_21]
at java.util.concurrent.FutureTask.run(Unknown Source) [:1.7.0_21]
at com.sun.faces.util.ExpiringConcurrentCache.get(ExpiringConcurrentCache.java:114) [jsf-impl-2.1.3-b02-jbossorg-2.jar:2.1.3-SNAPSHOT]
at com.sun.faces.facelets.impl.DefaultFaceletCache.getViewMetadataFacelet(DefaultFaceletCache.java:143) [jsf-impl-2.1.3-b02-jbossorg-2.jar:2.1.3-SNAPSHOT]
at com.sun.faces.facelets.impl.DefaultFaceletCache.getViewMetadataFacelet(DefaultFaceletCache.java:62) [jsf-impl-2.1.3-b02-jbossorg-2.jar:2.1.3-SNAPSHOT]
at com.sun.faces.facelets.impl.DefaultFaceletFactory.getMetadataFacelet(DefaultFaceletFactory.java:260) [jsf-impl-2.1.3-b02-jbossorg-2.jar:2.1.3-SNAPSHOT]
at com.sun.faces.facelets.impl.DefaultFaceletFactory.getMetadataFacelet(DefaultFaceletFactory.java:209) [jsf-impl-2.1.3-b02-jbossorg-2.jar:2.1.3-SNAPSHOT]
at com.sun.faces.application.view.ViewMetadataImpl.createMetadataView(ViewMetadataImpl.java:114) [jsf-impl-2.1.3-b02-jbossorg-2.jar:2.1.3-SNAPSHOT]
at com.sun.faces.lifecycle.RestoreViewPhase.execute(RestoreViewPhase.java:233) [jsf-impl-2.1.3-b02-jbossorg-2.jar:2.1.3-SNAPSHOT]
at com.sun.faces.lifecycle.Phase.doPhase(Phase.java:101) [jsf-impl-2.1.3-b02-jbossorg-2.jar:2.1.3-SNAPSHOT]
at com.sun.faces.lifecycle.RestoreViewPhase.doPhase(RestoreViewPhase.java:116) [jsf-impl-2.1.3-b02-jbossorg-2.jar:2.1.3-SNAPSHOT]
at com.sun.faces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:118) [jsf-impl-2.1.3-b02-jbossorg-2.jar:2.1.3-SNAPSHOT]
at javax.faces.webapp.FacesServlet.service(FacesServlet.java:593) [jboss-jsf-api_2.1_spec-2.0.0.Beta1.jar:2.0.0.Beta1]
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:329) [jbossweb-7.0.1.Final.jar:7.0.2.Final]
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:248) [jbossweb-7.0.1.Final.jar:7.0.2.Final]
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:275) [jbossweb-7.0.1.Final.jar:7.0.2.Final]
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:161) [jbossweb-7.0.1.Final.jar:7.0.2.Final]
at org.jboss.as.web.security.SecurityContextAssociationValve.invoke(SecurityContextAssociationValve.java:139) [jboss-as-web-7.0.2.Final.jar:7.0.2.Final]
at org.jboss.as.web.NamingValve.invoke(NamingValve.java:57) [jboss-as-web-7.0.2.Final.jar:7.0.2.Final]
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:154) [jbossweb-7.0.1.Final.jar:7.0.2.Final]
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102) [jbossweb-7.0.1.Final.jar:7.0.2.Final]
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109) [jbossweb-7.0.1.Final.jar:7.0.2.Final]
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:362) [jbossweb-7.0.1.Final.jar:7.0.2.Final]
at org.apache.coyote.http11.Http11AprProcessor.process(Http11AprProcessor.java:897) [jbossweb-7.0.1.Final.jar:7.0.2.Final]
at org.apache.coyote.http11.Http11AprProtocol$Http11ConnectionHandler.process(Http11AprProtocol.java:626) [jbossweb-7.0.1.Final.jar:7.0.2.Final]
at org.apache.tomcat.util.net.AprEndpoint$Worker.run(AprEndpoint.java:2054) [jbossweb-7.0.1.Final.jar:7.0.2.Final]
at java.lang.Thread.run(Unknown Source) [:1.7.0_21]

Please i need some help , i have changed my jdk version from 1.6 to 1.7 and the problem remains. I guess it's not a compiler problem Regards

BalusC
  • 1,082,665
  • 372
  • 3,610
  • 3,555
user2360260
  • 11
  • 1
  • 1
  • 1
    Why are you trying to compile javascript? What does this have to do with spring or jboss? – Mike Brant May 07 '13 at 23:38
  • i am working with spring and jboss , i am not trying to compile my javascript , this error appears when i run my xhtml page which contains && – user2360260 May 07 '13 at 23:43
  • @MikeBrant It is a JSF page, the server compiles it into a Servlet. Think of it as an expanded JSP. The JS must be inside the .xhtml code. – SJuan76 May 07 '13 at 23:44
  • I would say the .xhtml page is not correctly formed (some tag is missing its end, or something like that). What happens if you remove the line? (does it work well apart the JS?). Anyway, a trick that you can try is include your JS inside a `<![CDATA[` myJavascript; `]]>` structure (not that it should not work without that). – SJuan76 May 07 '13 at 23:47
  • if i remove this line it works , i think it's a problem with jsf compiler. I will try CDATA , thank you guys – user2360260 May 07 '13 at 23:51
  • It's not a problem with your compiler or with eclipse, it's just the way XML works. You have to escape `&` and `<` wherever PCDATA is expected. Simplest thing to do is put the script in a separate .js file. – Dagg Nabbit May 07 '13 at 23:58
  • i think the best way is puting the script in js file , thank you – user2360260 May 08 '13 at 00:07
  • possible duplicate of [The entity name must immediately follow the '&' in the entity reference](http://stackoverflow.com/a/16328808) – BalusC May 08 '13 at 01:22

1 Answers1

2

In XHTML, the ampersand will be parsed as a character not an operator unless you wrap the JavaScript in CDATA:

<![CDATA[
// your code
]]>

The error you provided says The entity name must immediately follow the '&' in the entity reference. This is telling you that it was expecting an entity name such as quot or amp, as in &quot; and &amp;. The error was triggered because instead of an entity name, it encountered another ampersand.

See this answer for more: When is a CDATA section necessary within a script tag?

Community
  • 1
  • 1
Rick Viscomi
  • 8,180
  • 4
  • 35
  • 50