forked from spring-projects/spring-boot
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Work around brittle annotation scanning in Mojarra
FacesListener in Mojarra 2.2.12 (used in Glassfish 4.1.1) is a ServletContainerInitializer that’s annotated to handle types annotated with javax.annotation.Resource. OAuth2RestOperationsConfiguration.SessionScopedConfiguration is one such class. This leads to com.sun.faces.config.DelegatingAnnotationProvider calling getAnnotations on SessionScopedConfiguration.class. This fails with a java.lang.ArrayStoreException due to SessionScopedConfiguration being annotated with @ConditionalOnBean(OAuth2ClientConfiguration) and OAuth2ClientConfiguration not being on the classpath. DelegatingAnnotationProvider currently catches NoClassDefFoundErrors thrown during its annotation processing. It needs to be made more robust so that it also copes with an ArrayStoreException, in a similar way to how org.glassfish.apf.impl.AnnotationProcessorImpl was updated to fix GLASSFISH-21265 [1]. I’ve opened an issue to this effect [2]. In the meantime, we can work around the brittleness in DelegatingAnnotationProvider by restructuring SessionScopedConfiguration. This commit moves the use of @resource into a nested inner class, ClientContextConfiguration, while leaving the use of @ConditionalOnBean on SessionScopedConfiguration. This means that it is now ClientContextConfiguration that is passed to FacesListener and processed by DelegatingAnnotationProcessor, thereby avoiding exposing it to the @ConditionalOnBean annotation that it does not handle gracefully. A Glassfish-based deployment test has also been added to verify the fix. Closes spring-projectsgh-2079 Closes spring-projectsgh-4321 [1] https://java.net/jira/browse/GLASSFISH-21265 [2] https://java.net/jira/browse/JAVASERVERFACES-4076
- Loading branch information
1 parent
5c0ef30
commit c4122b8
Showing
7 changed files
with
243 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
101 changes: 101 additions & 0 deletions
101
spring-boot-deployment-tests/spring-boot-deployment-test-glassfish/pom.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,101 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> | ||
<modelVersion>4.0.0</modelVersion> | ||
<parent> | ||
<groupId>org.springframework.boot</groupId> | ||
<artifactId>spring-boot-deployment-tests</artifactId> | ||
<version>1.3.0.BUILD-SNAPSHOT</version> | ||
</parent> | ||
<artifactId>spring-boot-deployment-test-glassfish</artifactId> | ||
<packaging>war</packaging> | ||
<name>Spring Boot Glassfish Deployment Test</name> | ||
<description>Spring Boot Glassfish Deployment Test</description> | ||
<url>http://projects.spring.io/spring-boot/</url> | ||
<organization> | ||
<name>Pivotal Software, Inc.</name> | ||
<url>http://www.spring.io</url> | ||
</organization> | ||
<properties> | ||
<main.basedir>${basedir}/../..</main.basedir> | ||
<glassfish.version>4.1.1</glassfish.version> | ||
<cargo.container.id>glassfish4x</cargo.container.id> | ||
<cargo.container.url>http://download.oracle.com/glassfish/${glassfish.version}/release/glassfish-${glassfish.version}.zip</cargo.container.url> | ||
</properties> | ||
<dependencies> | ||
<dependency> | ||
<groupId>org.springframework.boot</groupId> | ||
<artifactId>spring-boot-starter-web</artifactId> | ||
<exclusions> | ||
<exclusion> | ||
<groupId>org.springframework.boot</groupId> | ||
<artifactId>spring-boot-starter-tomcat</artifactId> | ||
</exclusion> | ||
</exclusions> | ||
</dependency> | ||
<dependency> | ||
<groupId>javax.servlet</groupId> | ||
<artifactId>javax.servlet-api</artifactId> | ||
<scope>provided</scope> | ||
</dependency> | ||
</dependencies> | ||
<build> | ||
<plugins> | ||
<plugin> | ||
<groupId>org.codehaus.mojo</groupId> | ||
<artifactId>build-helper-maven-plugin</artifactId> | ||
<executions> | ||
<execution> | ||
<id>reserve-network-port</id> | ||
<goals> | ||
<goal>reserve-network-port</goal> | ||
</goals> | ||
<phase>process-resources</phase> | ||
<configuration> | ||
<portNames> | ||
<portName>appserver.port</portName> | ||
<portName>appserver.admin.port</portName> | ||
<portName>appserver.jms.port</portName> | ||
<portName>appserver.iiop.port</portName> | ||
<portName>appserver.https.port</portName> | ||
<portName>appserver.iiops.port</portName> | ||
<portName>appserver.iiopmutualauth.port</portName> | ||
<portName>appserver.jmx.port</portName> | ||
<portName>appserver.osgishell.port</portName> | ||
<portName>appserver.debugger.port</portName> | ||
</portNames> | ||
</configuration> | ||
</execution> | ||
</executions> | ||
</plugin> | ||
<plugin> | ||
<groupId>org.codehaus.cargo</groupId> | ||
<artifactId>cargo-maven2-plugin</artifactId> | ||
<configuration> | ||
<configuration> | ||
<properties> | ||
<cargo.servlet.port>${appserver.port}</cargo.servlet.port> | ||
<cargo.glassfish.admin.port>${appserver.admin.port}</cargo.glassfish.admin.port> | ||
<cargo.glassfish.domain.jmxPort>${appserver.jmx.port}</cargo.glassfish.domain.jmxPort> | ||
<cargo.glassfish.http.ssl.port>${appserver.https.port}</cargo.glassfish.http.ssl.port> | ||
<cargo.glassfish.java.debugger.port>${appserver.debugger.port}</cargo.glassfish.java.debugger.port> | ||
<cargo.glassfish.jms.port>${appserver.jms.port}</cargo.glassfish.jms.port> | ||
<cargo.glassfish.orb.listener.port>${appserver.iiop.port}</cargo.glassfish.orb.listener.port> | ||
<cargo.glassfish.orb.mutualauth.port>${appserver.iiopmutualauth.port}</cargo.glassfish.orb.mutualauth.port> | ||
<cargo.glassfish.orb.ssl.port>${appserver.iiops.port}</cargo.glassfish.orb.ssl.port> | ||
<cargo.glassfish.osgi.shell.telnet.port>${appserver.osgishell.port}</cargo.glassfish.osgi.shell.telnet.port> | ||
</properties> | ||
</configuration> | ||
</configuration> | ||
</plugin> | ||
<plugin> | ||
<groupId>org.apache.maven.plugins</groupId> | ||
<artifactId>maven-failsafe-plugin</artifactId> | ||
<configuration> | ||
<systemPropertyVariables> | ||
<port>${appserver.port}</port> | ||
</systemPropertyVariables> | ||
</configuration> | ||
</plugin> | ||
</plugins> | ||
</build> | ||
</project> |
30 changes: 30 additions & 0 deletions
30
...nt-tests/spring-boot-deployment-test-glassfish/src/main/java/sample/SampleController.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
/* | ||
* Copyright 2012-2015 the original author or authors. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package sample; | ||
|
||
import org.springframework.web.bind.annotation.RequestMapping; | ||
import org.springframework.web.bind.annotation.RestController; | ||
|
||
@RestController | ||
public class SampleController { | ||
|
||
@RequestMapping("/") | ||
public String hello() { | ||
return "Hello World"; | ||
} | ||
|
||
} |
25 changes: 25 additions & 0 deletions
25
...boot-deployment-test-glassfish/src/main/java/sample/SampleGlassfishDeployApplication.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
/* | ||
* Copyright 2012-2015 the original author or authors. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package sample; | ||
|
||
import org.springframework.boot.autoconfigure.SpringBootApplication; | ||
import org.springframework.boot.context.web.SpringBootServletInitializer; | ||
|
||
@SpringBootApplication | ||
public class SampleGlassfishDeployApplication extends SpringBootServletInitializer { | ||
|
||
} |
44 changes: 44 additions & 0 deletions
44
...ot-deployment-test-glassfish/src/test/java/sample/SampleGlassfishDeployApplicationIT.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
/* | ||
* Copyright 2012-2015 the original author or authors. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package sample; | ||
|
||
import org.junit.Test; | ||
|
||
import org.springframework.boot.test.TestRestTemplate; | ||
import org.springframework.http.HttpStatus; | ||
import org.springframework.http.ResponseEntity; | ||
|
||
import static org.junit.Assert.assertEquals; | ||
|
||
/** | ||
* Integration Tests for {@link SampleGlassfishDeployApplication}. | ||
*/ | ||
public class SampleGlassfishDeployApplicationIT { | ||
|
||
private int port = Integer.valueOf(System.getProperty("port")); | ||
|
||
@Test | ||
public void testHome() throws Exception { | ||
String url = "http://localhost:" + this.port + "/bootapp/"; | ||
System.out.println(url); | ||
ResponseEntity<String> entity = new TestRestTemplate().getForEntity(url, | ||
String.class); | ||
assertEquals(HttpStatus.OK, entity.getStatusCode()); | ||
assertEquals("Hello World", entity.getBody()); | ||
} | ||
|
||
} |
26 changes: 26 additions & 0 deletions
26
...ple-devtools/src/test/java/sample/devtools/SampleDevToolsApplicationIntegrationTests.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
/* | ||
* Copyright 2012-2015 the original author or authors. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package sample.devtools; | ||
|
||
/** | ||
* Integration tests for {@link SampleDevToolsApplication}. | ||
* | ||
* @author Andy Wilkinson | ||
*/ | ||
public class SampleDevToolsApplicationIntegrationTests { | ||
|
||
} |