Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [jetty-users] ClassCast on parsing virtualHosts

as.maps, 
Nope, it's a DTD issue, like Jan pointed out.
Either a lack of DTD or the wrong DTD is the root cause.
Fix that and it will work.

Feel free to experiment in the jetty-distribution.
Edit the demo-base/webapps/test.xml
Enable the virtualHosts section (which is commented out)
Run the demo base.
   [demo-base]$ java -jar ../start.jar
It works.
Now remove the DTD line and try again
   [demo-base]$ java -jar ../start.jar
2013-12-01 16:59:37.267:WARN:oejx.XmlConfiguration:main: Config error at <Set name="virtualHosts">|    <Array type="String">|      <Item>www.MyVirtualDomain.com</Item>|      <Item>m.MyVirtualDomain.com</Item>|      <Item>*.OtherVirtualDomain.com</Item>|      <Item>@ConnectorName</Item>|      <Item>localhost</Item>|      <Item>127.0.0.1</Item>|    </Array>|  </Set> java.lang.ClassCastException: java.lang.String cannot be cast to org.eclipse.jetty.xml.XmlParser$Node in file:/home/joakim/code/intalio/distros/jetty-distribution-9.1.0.v20131115/demo-base/webapps/test.xml
2013-12-01 16:59:37.267:WARN:oejd.DeploymentManager:main: Unable to reach node goal: started
java.lang.ClassCastException: java.lang.String cannot be cast to org.eclipse.jetty.xml.XmlParser$Node
at org.eclipse.jetty.xml.XmlConfiguration$JettyXmlConfiguration.newArray(XmlConfiguration.java:872)

   

--
Joakim Erdfelt <joakim@xxxxxxxxxxx>
Expert advice, services and support from from the Jetty & CometD experts


On Sun, Dec 1, 2013 at 4:06 PM, <as.maps@xxxxxxxxx> wrote:
While I am not an expert on this topic, I guess the problem arises from

<Array type="java.lang.String">
...
</Array>

To fix the issue, first thing I would try is to omit the 'type' attribute, so it reads:

<Array>
  <Item>example.com</Item>
</Array>

>From my understanding (which is close to nothing) Jetty XML then would not try to parse the Array Items to a string but use the bare generic org.eclipse.jetty.xml.XmlParser$Node class.

>From my quick look at the sources, it could also be a 'special border case'. To verify, could you just try inserting another item? Like so


<Configure class="org.eclipse.jetty.webapp.WebAppContext">
  <Set name="contextPath">/</Set>
  <Set name="war">/opt/nexus-2.6.3.war</Set>
  <Set name="virtualHosts">
     <Array type="java.lang.String">
       <Item>example.com</Item>
       <Item>example.org</Item>
     </Array>
  </Set>
</Configure>

Hope this helps.

- Andreas

------ Originalnachricht ------
Von: "Jan Bartel" <janb@xxxxxxxxxxx>
An: "JETTY user mailing list" <jetty-users@xxxxxxxxxxx>
Gesendet: 01.12.2013 23:47:06
Betreff: Re: [jetty-users] ClassCast on parsing virtualHosts

Rafal,

Check your 2nd line of the xml config file is the right version for
jetty-9.x. It should be:

<!DOCTYPE Configure PUBLIC "-//Jetty//Configure//EN"
"http://www.eclipse.org/jetty/configure_9_0.dtd">

Jan

On 2 December 2013 05:50, Rafał Krupiński <r.krupinski+jetty@xxxxxxxxx> wrote:
 Hi

 I'm trying to setup a virtual hosts on my jetty 9 based on these
 instructions:
 http://www.eclipse.org/jetty/documentation/current/configuring-virtual-hosts.html

 this is my webapp.xml:

 <Configure class="org.eclipse.jetty.webapp.WebAppContext">
     <Set name="contextPath">/</Set>
     <Set name="war">/opt/nexus-2.6.3.war</Set>
     <Set name="virtualHosts">
         <Array type="java.lang.String">
             <Item>example.com</Item>
         </Array>
     </Set>
 </Configure>

 and it causes this error to appear in logs:

 2013-12-01 18:29:13.097:WARN:oejx.XmlConfiguration:main: Config error at
 <Set name="virtualHosts">|??<Array
 type="java.lang.String">|???<Item>example.com</Item>|??</Array>|?</Set>
 java.lang.ClassCastException: java.lang.String cannot be cast to
 org.eclipse.jetty.xml.XmlParser$Node in
 file:/usr/local/share/jetty9/webapps/nexus.xml
 2013-12-01 18:29:13.097:WARN:oejd.DeploymentManager:main: Unable to reach
 node goal: started
 java.lang.ClassCastException: java.lang.String cannot be cast to
 org.eclipse.jetty.xml.XmlParser$Node
         at
 org.eclipse.jetty.xml.XmlConfiguration$JettyXmlConfiguration.newArray(XmlConfiguration.java:872)
         at
 org.eclipse.jetty.xml.XmlConfiguration$JettyXmlConfiguration.itemValue(XmlConfiguration.java:1129)
         at
 org.eclipse.jetty.xml.XmlConfiguration$JettyXmlConfiguration.value(XmlConfiguration.java:1030)
         at
 org.eclipse.jetty.xml.XmlConfiguration$JettyXmlConfiguration.set(XmlConfiguration.java:457)
         at
 org.eclipse.jetty.xml.XmlConfiguration$JettyXmlConfiguration.configure(XmlConfiguration.java:411)
         at
 org.eclipse.jetty.xml.XmlConfiguration$JettyXmlConfiguration.configure(XmlConfiguration.java:354)
         at
 org.eclipse.jetty.xml.XmlConfiguration.configure(XmlConfiguration.java:262)
         at
 org.eclipse.jetty.deploy.providers.WebAppProvider.createContextHandler(WebAppProvider.java:290)
         at org.eclipse.jetty.deploy.App.getContextHandler(App.java:100)
         at
 org.eclipse.jetty.deploy.bindings.StandardDeployer.processBinding(StandardDeployer.java:36)
         at
 org.eclipse.jetty.deploy.AppLifeCycle.runBindings(AppLifeCycle.java:186)
         at
 org.eclipse.jetty.deploy.DeploymentManager.requestAppGoal(DeploymentManager.java:495)
         at
 org.eclipse.jetty.deploy.DeploymentManager.addApp(DeploymentManager.java:146)
         at
 org.eclipse.jetty.deploy.providers.ScanningAppProvider.fileAdded(ScanningAppProvider.java:175)
         at
 org.eclipse.jetty.deploy.providers.ScanningAppProvider$1.fileAdded(ScanningAppProvider.java:64)
         at org.eclipse.jetty.util.Scanner.reportAddition(Scanner.java:605)
 ...


 Please help.

 --
 Pozdrawiam
 Rafał Krupiński

 _______________________________________________
 jetty-users mailing list
 jetty-users@xxxxxxxxxxx
 https://dev.eclipse.org/mailman/listinfo/jetty-users




--
Jan Bartel <janb@xxxxxxxxxxx>
www.webtide.com
'Expert Jetty/CometD developer,production,operations advice'
_______________________________________________
jetty-users mailing list
jetty-users@xxxxxxxxxxx
https://dev.eclipse.org/mailman/listinfo/jetty-users

_______________________________________________
jetty-users mailing list
jetty-users@xxxxxxxxxxx
https://dev.eclipse.org/mailman/listinfo/jetty-users


Back to the top