java - what does this Spring JSON endpoint break in Jboss/Tomcat? -
what spring json endpoint break in jboss/tomcat ? tried add existing application , worked until started refactoring code , errors not point logical me.
here code controller , helper class keep things clean. controller.java
import java.io.ioexception; import java.util.properties; import javax.annotation.nonnull; import org.apache.commons.configuration.configurationexception; import org.springframework.beans.factory.annotation.autowired; import org.springframework.stereotype.controller; import org.springframework.web.bind.annotation.requestmapping; import org.springframework.web.bind.annotation.responsebody; @controller public class propertiesdisplaycontroller { @nonnull private final propertiesdisplayhelper propertieshelper; /** * @param propertieshelper */ @nonnull @autowired public propertiesdisplaycontroller(@nonnull final propertiesdisplayhelper propertieshelper) { super(); this.propertieshelper = propertieshelper; } @nonnull @requestmapping("/localproperties") public @responsebody properties localproperties() throws configurationexception, ioexception { return propertieshelper.getlocalproperties(); } @nonnull @requestmapping("/properties") public @responsebody properties applicationproperties() throws ioexception, configurationexception { return propertieshelper.getapplicationproperties(); } }
this helper.java
import java.io.fileinputstream; import java.io.ioexception; import java.util.iterator; import java.util.map; import java.util.properties; import java.util.treemap; import javax.annotation.nonnull; import org.apache.commons.configuration.configuration; import org.apache.commons.configuration.configurationexception; import org.apache.commons.io.ioutils; import org.apache.commons.lang.stringescapeutils; import org.apache.commons.lang.stringutils; public class propertiesdisplayhelper { /** static location of properties in sso */ private static string local_properties_location = "local.properties"; /** static strings masking passwords , blank values */ private static string novalue = "**no value**"; /** static strings masking passwords , blank values */ private static string masked = "**masked**"; @nonnull public properties getapplicationproperties() throws configurationexception { final properties properties = new properties(); final configuration configuration = appconfiguration.factory.getconfiguration(); // create map of properties final iterator<?> propertykeys = configuration.getkeys(); final map<string, string> sortedproperties = new treemap<string, string>(); // loops configurations , builds properties while (propertykeys.hasnext()) { final string key = propertykeys.next().tostring(); final string value = configuration.getproperty(key).tostring(); sortedproperties.put(key, value); } properties.putall(sortedproperties); // output of result formatspropertiesdata(properties); return properties; } @nonnull public properties getlocalproperties() throws configurationexception, ioexception { fileinputstream fis = null; final properties properties = new properties(); // imports file local.properties specified location // desinated when update openam12 try { fis = new fileinputstream(local_properties_location); properties.load(fis); } { // closes file input stream ioutils.closequietly(fis); } formatspropertiesdata(properties); return properties; } void formatspropertiesdata(@nonnull final properties properties) { (final string key : properties.stringpropertynames()) { string value = properties.getproperty(key); if (stringutils.isempty(value)) { value = novalue; } else if (key.endswith("ssword")) { value = masked; } else { value = stringescapeutils.escapehtml(value); } // places data k,v paired properties object properties.put(key, value); } } }
they set json display of properties in application , file logging. yet no intrusive code seems break entire application build.
here error jboss
20:33:41,559 error [org.jboss.as.server] (deploymentscanner-threads - 1) jbas015870: deploy of deployment "openam.war" rolled following failure message: {"jbas014671: failed services" => {"jboss.deployment.unit.\"application.war\".structure" => "org.jboss.msc.service.startexception in service jboss.deployment.unit.\"application.war\".structure: jbas018733: failed process phase structure of deployment \"application.war\" caused by: org.jboss.as.server.deployment.deploymentunitprocessingexception: jbas018740: failed mount deployment content caused by: java.io.filenotfoundexception:application.war (access denied)"}}
and errors tomcat
i @ lost here , think there not see.
a simple solution @ hand. missing component @component annotation on helper class.
Comments
Post a Comment