6

I am trying to import the xsd schema from local drive using schemalocation classpath in spring. I added the required file in the classpath and added the reference of this file with

15:10:19.336 [localhost-startStop-1] DEBUG o.s.b.f.xml.ResourceEntityResolver - Could not resolve XML entity [classpath:spring-social-facebook-1.1.xsd] against system root URL
java.net.MalformedURLException: unknown protocol: classpath
    at java.net.URL.<init>(Unknown Source) ~[na:1.8.0_31]
    at java.net.URL.<init>(Unknown Source) ~[na:1.8.0_31]
    at java.net.URL.<init>(Unknown Source) ~[na:1.8.0_31]

here is the header for my applicationContext.xml,

<beans xmlns="http://www.springframework.org/schema/beans"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:context="http://www.springframework.org/schema/context"
    xmlns:jdbc="http://www.springframework.org/schema/jdbc" xmlns:tx="http://www.springframework.org/schema/tx"
    xmlns:beans="http://www.springframework.org/schema/beans" xmlns:aop="http://www.springframework.org/schema/aop"
    xmlns:mongo="http://www.springframework.org/schema/data/mongo"     xmlns:mvc="http://www.springframework.org/schema/mvc"
    xmlns:social="http://www.springframework.org/schema/social"
    xmlns:facebook="http://www.springframework.org/schema/social/facebook"
    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/jdbc http://www.springframework.org/schema/jdbc/spring-jdbc-3.0.xsd
            http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-3.0.xsd
            http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-3.0.xsd
            http://www.springframework.org/schema/data/mongo http://www.springframework.org/schema/data/mongo/spring-mongo-1.7.xsd
            http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc.xsd
            http://www.springframework.org/schema/social http://www.springframework.org/schema/social/spring-social.xsd
            http://www.springframework.org/schema/social/facebook classpath:spring-social-facebook-1.1.xsd">

I am using spring 4.1 with and spring-bean version 3.0.

Muhammad Adnan
  • 490
  • 2
  • 12
  • 25
  • http://stackoverflow.com/questions/28267536/how-to-refer-to-a-classpath-xsd-in-xsischemalocation – Vartlok Aug 11 '15 at 10:20
  • 2
    Why are you even using `classpath:` as a prefix. It should be `http://www.springframework.org/schema/social/spring-social-facebook-1.1.xsd` instead of what you have now. Due to a custom resolver from spring it will load the xsd from the jar files on the classpath (as it does with all the other xsd files as well!). – M. Deinum Aug 11 '15 at 10:21
  • actually spring-social-facebook xsd is removed from the location **http://www.springframework.org/schema/social/spring-social-facebook-1.1.xsd** thats why i am tring to create the xsd locally and use that. – Muhammad Adnan Aug 11 '15 at 10:23
  • 1
    That doesn't matter as it is by default resolved from the included jar files, just as with the other xsd files from spring. If that doesn't work (and I would suggest using the version less schema), you are either missing jars on your classpath, using the wrong versions (not 1.1) or are using incompatible versions of Spring and Spring Social. – M. Deinum Aug 11 '15 at 10:27

2 Answers2

2

You shouldn't be messing around with other locations and use the defaults. For Spring Social Facebook you should use http://www.springframework.org/schema/social/spring-social-facebook-1.1.xsd or preferably the version less one http://www.springframework.org/schema/social/spring-social-facebook.xsd.

Spring will always first load the xsd from the jars from the classpath. Spring ships with a custom EntityResolver, the PluggableSchemaResolver which uses the different spring.schemas files in the META-INF directory of Spring jar files.

The only reasons to get an error like you get (and why you try to work around it) is

  1. You haven't included the spring-social-facebook needed dependencies
  2. You have included the wrong spring-social-facebook dependencies
  3. You are using incompatible Spring and Spring Social versions.

I would bet on option 2 not having all the 1.1.0 versions of spring-social-facebook but mixing versions of jars.

M. Deinum
  • 115,695
  • 22
  • 220
  • 224
1

I have resolved the issue, as i was using the wrong jar of spring-social-web but not spring-social-facebook that contain the xsd. I don't required to use the classpath any more. thanks M. Deinum.

Community
  • 1
  • 1
Muhammad Adnan
  • 490
  • 2
  • 12
  • 25