I was wondering if there are any spring boot users. I plan on writing some
docs as it is harder than it should be.
I was able to successfully implement it though. Where are you stuck
exactly?
Here's the main init code:
package com.alphatheory.configuration;
import com.mycompany.ATInit;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.apache.axis2.transport.http.AxisServlet;
import org.springframework.boot.web.servlet.ServletContextInitializer;
import org.springframework.context.annotation.Configuration;
import
org.springframework.web.context.support.AnnotationConfigWebApplicationContext;
import org.springframework.core.annotation.Order;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.PropertySource;
import
org.springframework.context.support.PropertySourcesPlaceholderConfigurer;
import javax.servlet.ServletContext;
import javax.servlet.ServletRegistration;
import java.util.Set;
@Configuration
@Order(4)
@PropertySource("classpath:application.properties")
public class ATWebAppInitializer implements ServletContextInitializer {
private static final Logger logger =
LogManager.getLogger(ATWebAppInitializer.class);
private static final String SERVICES_MAPPING = "/services/*";
@Value("${appInstance}")
private String appInstance;
@Value("${appInstanceIP}")
private String appInstanceIP;
@Value("${prodKillSwitchEnabled}")
private String prodKillSwitchEnabled;
@Override
public void onStartup(ServletContext container) {
String logPrefix = "ATWebAppInitializer , appInstance: " +
appInstance + " , ";
logger.warn(logPrefix + "inside onStartup() ...");
// Create the 'root' Spring application context
AnnotationConfigWebApplicationContext ctx = new
AnnotationConfigWebApplicationContext();
addAxis2Servlet(container, ctx);
addATInitServlet(container, ctx);
logger.warn(logPrefix + "onStartup() completed ...");
}
private void addAxis2Servlet(ServletContext container,
AnnotationConfigWebApplicationContext ctx) {
ServletRegistration.Dynamic dispatcher = container.addServlet(
"AxisServlet", new AxisServlet());
dispatcher.setLoadOnStartup(1);
Set<String> mappingConflicts =
dispatcher.addMapping(SERVICES_MAPPING);
if (!mappingConflicts.isEmpty()) {
for (String s : mappingConflicts) {
logger.error("Mapping conflict: " + s);
}
// throw new IllegalStateException("'AxisServlet' could not be
mapped to '" + SERVICES_MAPPING + "'");
}
}
private void addATInitServlet(ServletContext container,
AnnotationConfigWebApplicationContext ctx) {
ServletRegistration.Dynamic dispatcher = container.addServlet(
"ATInit", new ATInit());
dispatcher.setLoadOnStartup(1);
dispatcher.setInitParameter("appInstance", appInstance);
// do not add mapping
}
}
On Tue, Mar 9, 2021 at 10:13 AM Kevin Lee <[email protected]>
wrote:
> Hi Axis2 team,
>
> I recently had to upgrade from Axis 1.6.3 to Axis 1.7.8 on the Java Spring
> Boot codebase I work on, and struggled greatly with making the upgrade work
> until I resolved the breaking change from AXIS2-5340
> <https://issues.apache.org/jira/browse/AXIS2-5340> that involved changing
> our axis2.xml config to properly deploy our web services.
>
> This breaking change is not listed clearly in the 1.7.0 major release
> notes <https://axis.apache.org/axis2/java/core/release-notes/1.7.0.html> -
> it is not included alongside the other breaking changes listed up front
> such as the MEP URI form change, and is tucked away in the complete list
> of JIRA issues that were addressed in the release
> <https://axis.apache.org/axis2/java/core/release-notes/1.7.0.html>. The
> only reason why I found out about this change was by downloading the
> binaries for 1.6.3 and 1.7.8 and stumbling upon the differences in default
> axis2.xml configs.
>
> As mentioned in the issue, this seems like a rather important breaking
> change that will apply to the majority of Axis2 setups and seems necessary
> for backward compatibility. I believe it will benefit future developers
> that have to do similar upgrades to make note of this breaking change and
> include it in the 1.7.0 major release notes where it can be visibly seen.
>
> Best,
> Kevin Lee
>
>