In attempting to set up OAuth2 for interfacing with Geonode, the plug in 
geoserver-2.21-SNAPSHOT-sec-oauth2-geonode-plugin.zip, would give an error in 
the geoserver.log

02 009 23:09:50 WARN   [support.XmlWebApplicationContext] - Exception 
encountered during context initialization - cancelling refresh attempt: 
org.springframework.beans.factory.BeanCreationException: Error creating bean 
with name 'geoNodeOAuth2TokenServices' defined in URL 
[jar:file:/var/lib/tomcat9/webapps/geoserver/WEB-INF/lib/gs-sec-oauth2-geonode-2.21-SNAPSHOT.jar!/applicationContext.xml]:
 Instantiation of bean failed; nested exception is 
org.springframework.beans.BeanInstantiationException: Failed to instantiate 
[org.geoserver.security.oauth2.services.GeoNodeTokenServices]: Constructor 
threw exception; nested exception is 
javax.xml.stream.FactoryConfigurationError: Provider for 
javax.xml.stream.XMLOutputFactory cannot be found
02 009 23:09:50 WARN   [support.DisposableBeanAdapter] - Invocation of destroy 
method failed on bean with name 'geoServerLoader': 
java.lang.NullPointerException
02 009 23:09:50 ERROR  [context.ContextLoader] - Context initialization failed
org.springframework.beans.factory.BeanCreationException: Error creating bean 
with name 'geoNodeOAuth2TokenServices' defined in URL 
[jar:file:/var/lib/tomcat9/webapps/geoserver/WEB-INF/lib/gs-sec-oauth2-geonode-2.21-SNAPSHOT.jar!/applicationContext.xml]:
 Instantiation of bean failed; nested exception is 
org.springframework.beans.BeanInstantiationException: Failed to instantiate 
[org.geoserver.security.oauth2.services.GeoNodeTokenServices]: Constructor 
threw exception; nested exception is 
javax.xml.stream.FactoryConfigurationError: Provider for 
javax.xml.stream.XMLOutputFactory cannot be found

I am able to replicate this by installing a fresh geoserver, 
geoserver-2.21.1-war.zip, verify that that runs and then installing the 
offending package and breaking the install.

Executing the package unzip without allowing replacements I have a package diff 
list of,

# These are in the default geoserver install
replace geoserver/WEB-INF/lib/spring-context-support-5.2.22.RELEASE.jar? [y]es, 
[n]o, [A]ll, [N]one, [r]ename: n
replace geoserver/WEB-INF/lib/jettison-1.4.1.jar? [y]es, [n]o, [A]ll, [N]one, 
[r]ename: n
replace geoserver/WEB-INF/lib/spring-security-web-5.1.13.RELEASE.jar? [y]es, 
[n]o, [A]ll, [N]one, [r]ename: n
replace geoserver/WEB-INF/lib/spring-aop-5.2.22.RELEASE.jar? [y]es, [n]o, 
[A]ll, [N]one, [r]ename: n
replace geoserver/WEB-INF/lib/spring-webmvc-5.2.22.RELEASE.jar? [y]es, [n]o, 
[A]ll, [N]one, [r]ename: n
replace geoserver/WEB-INF/lib/spring-context-5.2.22.RELEASE.jar? [y]es, [n]o, 
[A]ll, [N]one, [r]ename: n
replace geoserver/WEB-INF/lib/jackson-databind-2.13.2.1.jar? [y]es, [n]o, 
[A]ll, [N]one, [r]ename: n
replace geoserver/WEB-INF/lib/spring-security-core-5.1.13.RELEASE.jar? [y]es, 
[n]o, [A]ll, [N]one, [r]ename: n
replace geoserver/WEB-INF/lib/jackson-core-2.13.2.jar? [y]es, [n]o, [A]ll, 
[N]one, [r]ename: n
replace geoserver/WEB-INF/lib/commons-codec-1.15.jar? [y]es, [n]o, [A]ll, 
[N]one, [r]ename: n
replace geoserver/WEB-INF/lib/spring-security-config-5.1.13.RELEASE.jar? [y]es, 
[n]o, [A]ll, [N]one, [r]ename: n
replace geoserver/WEB-INF/lib/jackson-annotations-2.13.2.jar? [y]es, [n]o, 
[A]ll, [N]one, [r]ename: n
replace geoserver/WEB-INF/lib/json-lib-2.4.2-geoserver.jar? [y]es, [n]o, [A]ll, 
[N]one, [r]ename: n

# These are added by the package
  inflating: geoserver/WEB-INF/lib/jackson-mapper-asl-1.9.13.jar
  inflating: geoserver/WEB-INF/lib/jackson-coreutils-1.12.jar
  inflating: geoserver/WEB-INF/lib/json-lib-2.4-jdk15.jar
  inflating: geoserver/WEB-INF/lib/jackson-datatype-jsr310-2.8.11.jar
  inflating: geoserver/WEB-INF/lib/jsonld-java-0.12.5.jar
  inflating: geoserver/WEB-INF/lib/json-patch-1.12.jar
  inflating: geoserver/WEB-INF/lib/jackson-core-asl-1.9.13.jar
  inflating: geoserver/WEB-INF/lib/jackson-dataformat-cbor-2.6.6.jar
  inflating: geoserver/WEB-INF/lib/gs-sec-oauth2-core-2.21-SNAPSHOT.jar
  inflating: geoserver/WEB-INF/lib/gs-sec-oauth2-geonode-2.21-SNAPSHOT.jar
  inflating: geoserver/WEB-INF/lib/gs-sec-oauth2-web-2.21-SNAPSHOT.jar
  inflating: geoserver/WEB-INF/lib/spring-security-saml2-core-1.0.3.RELEASE.jar
  inflating: geoserver/WEB-INF/lib/json-smart-2.3.jar
  inflating: geoserver/WEB-INF/lib/spring-security-jwt-1.0.11.RELEASE.jar
  inflating: geoserver/WEB-INF/lib/json-path-2.4.0.jar
  inflating: geoserver/WEB-INF/lib/spring-security-oauth2-2.0.16.RELEASE.jar
  inflating: geoserver/WEB-INF/lib/jackson-dataformat-yaml-2.13.2.jar
  inflating: geoserver/WEB-INF/lib/jackson-dataformat-xml-2.13.2.jar

Searching the libraries resulted in two libraries with a matching string:

$ find tomcat9/webapps/geoserver/WEB-INF/lib/ -name "*.jar" | xargs grep 
XMLOutputFactory
Binary file geoserver/WEB-INF/lib/jettison-1.4.1.jar matches
Binary file geoserver/WEB-INF/lib/xml-apis-1.4.01.jar matches

Only one of these, xml-apis-1.4.01.jar, has the necessary class, 
javax/xml/stream/XMLOutputFactory.class. This jar is stock with the geoserver 
install and is not included with the dependencies of the OAuth2 package.

I was playing around trying to get it to work and hopefully provide a solution, 
but I don’t know enough of java on how to include this sort of thing.
I tried adding, to the 
META-INF/maven/org.geoserver.community/gs-sec-oauth2-geonode/pom.xml
    <dependency>
      <groupId>org.apache.xmlcommons.Version</groupId>
      <artifactId>xml-commons</artifactId>
    </dependency>

But this did not work. A search for the offending bean in the expanded jar led 
to:
$ grep -rn "." -e "GeoNodeTokenServices"
Binary file ./org/geoserver/security/oauth2/services/GeoNodeTokenServices.class 
matches
./applicationContext.xml:27:            <bean id="geoNodeOAuth2TokenServices" 
class="org.geoserver.security.oauth2.services.GeoNodeTokenServices">

But I don’t know how to include the needed class,

        <!-- OAuth2 Security Extension -->
                <bean id="geoNodeOAuth2TokenServices" 
class="org.geoserver.security.oauth2.services.GeoNodeTokenServices">

                </bean>

                <bean id="geoNodeOAuth2AuthenticationProvider"
                        
class="org.geoserver.security.oauth2.GeoNodeOAuth2AuthenticationProvider">
                        <constructor-arg ref="authenticationManager" />
                        <constructor-arg value="geoNodeOAuth2TokenServices" />
                        <constructor-arg 
value="geoNodeOAuth2SecurityConfiguration" />
                        <constructor-arg value="geoNodeOauth2RestTemplate" />
                </bean>



I expanded the library, xml-apis-1.4.01.jar, and confirmed that the needed 
class was contained inside:
$ jar -xvf xml-apis-1.4.01.jar
...
 inflated: javax/xml/stream/XMLOutputFactory.class
...

Its manifest, META-INF/MANIFEST.MF, has the following:

Manifest-Version: 1.0
Ant-Version: Apache Ant 1.7.0
Created-By: 1.3.1 (IBM Corporation)

Name: org/apache/xmlcommons/Version
Comment: XmlCommonsExternal for http://xml.apache.org/ subproject's us
 e
Implementation-Title: org.apache.xmlcommons.Version
Implementation-Version: 1.4.01
Implementation-Vendor: Apache Software Foundation
Implementation-URL: http://xml.apache.org/commons/

...

Name: javax/xml/stream/
Comment: xml-commons for http://xml.apache.org/ subproject's use
Specification-Title: Streaming API for XML (StAX) 1.0
Specification-Vendor: BEA Systems, Inc.
Specification-Version: 1.0
Implementation-Title: javax.xml.stream
Implementation-Version: 1.4.01
Implementation-Vendor: Apache Software Foundation
Implementation-URL: http://xml.apache.org/commons/ 
<http://xml.apache.org/commons/>

...

Thank you for your help.

Cal Abel

Attachment: signature.asc
Description: Message signed with OpenPGP

_______________________________________________
Geoserver-users mailing list

Please make sure you read the following two resources before posting to this 
list:
- Earning your support instead of buying it, but Ian Turton: 
http://www.ianturton.com/talks/foss4g.html#/
- The GeoServer user list posting guidelines: 
http://geoserver.org/comm/userlist-guidelines.html

If you want to request a feature or an improvement, also see this: 
https://github.com/geoserver/geoserver/wiki/Successfully-requesting-and-integrating-new-features-and-improvements-in-GeoServer


Geoserver-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/geoserver-users

Reply via email to