04/27/2005: Getting Spring to Work Inside Sonic XIS XML Server
I encountered an exception trying to use Spring inside the Sonic XIS XML server:
java.lang.ExceptionInInitializerError: java.lang.NullPointerException at org.springframework.core.io.ClassPathResource.getURL(ClassPathResource.java:144) at org.springframework.core.io.ClassPathResource.getFile(ClassPathResource.java:154) ...
This issue happened because XIS has no context class load for the current thread. In order to workaround this problem, I updated the ClassPathResource class in the spring-core.jar file.
I created the following method:
private ClassLoader getClassLoader() { ClassLoader rv = this.classLoader; if (rv == null) { // no class loader specified -> use thread context class loader rv = Thread.currentThread().getContextClassLoader(); } if (rv == null) { rv = getClass().getClassLoader(); } return rv; }
And updated the following two methods:
public InputStream getInputStream() throws IOException { InputStream is = null; if (this.clazz != null) { is = this.clazz.getResourceAsStream(this.path); } else { is = getClassLoader().getResourceAsStream(this.path); } if (is == null) { throw new FileNotFoundException( getDescription() + " cannot be opened because it does not exist"); } return is; } public URL getURL() throws IOException { URL url = null; if (this.clazz != null) { url = this.clazz.getResource(this.path); } else { url = getClassLoader().getResource(this.path); } if (url == null) { throw new FileNotFoundException( getDescription() + " cannot be resolved to URL because it does not exist"); } return url; }
After these changes, it was a simple matter to create my custom spring-core-wwre.jar file.
03/23/2005: World of Warcraft Website Uses Spring!
The World of Warcraft site is having problems. I got the following Java exception
org.springframework.jdbc.CannotGetJdbcConnectionException: Could not get JDBC connection; nested exception is java.sql.SQLException: ORA-01017: invalid username/password; logon denied org.springframework.jdbc.datasource.DataSourceUtils.getConnection(DataSourceUtils.java:155) org.springframework.jdbc.datasource.DataSourceUtils.getConnection(DataSourceUtils.java:128) org.springframework.jdbc.core.JdbcTemplate.execute(JdbcTemplate.java:616) org.springframework.jdbc.core.JdbcTemplate.call(JdbcTemplate.java:653) org.springframework.jdbc.object.StoredProcedure.execute(StoredProcedure.java:100) com.blizzard.account.db.procedures.AccDBIStoredProcedure.safeExecute(AccDBIStoredProcedure.java:33) com.blizzard.account.db.procedures.AccGetAccIdByAccNameSP.execute(AccGetAccIdByAccNameSP.java:51) com.blizzard.account.db.AccountManager.getAccIdByAccName(AccountManager.java:720) com.blizzard.wow.web.loginSupport.action.controller.form.RequestPasswordFormController.onBind(RequestPasswordFormController.java:288) org.springframework.web.servlet.mvc.BaseCommandController.bindAndValidate(BaseCommandController.java:295) org.springframework.web.servlet.mvc.AbstractFormController.handleRequestInternal(AbstractFormController.java:236) org.springframework.web.servlet.mvc.AbstractController.handleRequest(AbstractController.java:128) org.springframework.web.servlet.mvc.SimpleControllerHandlerAdapter.handle(SimpleControllerHandlerAdapter.java:44) org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:522) org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:321) javax.servlet.http.HttpServlet.service(HttpServlet.java:802) com.blizzard.wow.web.filter.WelcomeFilter.doFilter(WelcomeFilter.java:52) org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:73) org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:73)