我正在使用Grizzly2和Jersey创建一个嵌入式服务器,并且需要从注入到所有Rest连接加载配置。我试图了解一般的注射方式。我尝试过测试但没有工作。
public class ConfigBinder extends AbstractBinder{
@Override
protected void configure() {
bind(BinderTeste.class).to(restMainService.class);
}
}
public class BinderTeste {
public String bTeste = "BTESTE";
public BinderTeste(){
}
}
每次我尝试连接时都会得到这个:
mai 07, 2015 5:23:53 PM org.glassfish.jersey.server.ServerRuntime$Responder process
GRAVE: Error occurred when processing a response created from an already mapped exception.
编辑:
public class AppWS extends ResourceConfig {
public AppWS(String db){
CFFMasterClass MasterClass = new CFFMasterClass();
setConfig(MasterClass.getCurrentConfig());
InicializaLogger();
try{
File currentPath = null;
if(this.getClass().getProtectionDomain().getCodeSource().getLocation().getPath().contains("jar")){
currentPath = new File(this.getClass().getProtectionDomain().getCodeSource().getLocation().getPath());
System.out.println(currentPath.getPath().substring(0,currentPath.getPath().lastIndexOf(File.separator)));
ExtractWSMethods(new File(currentPath.getPath().substring(0,currentPath.getPath().lastIndexOf(File.separator))));
}else{
currentPath = new File("c://CompuService//lib");
ExtractWSMethods(currentPath);
}
register(MultiPartFeature.class);
}catch(Exception ex){
GeraLog.error(ex.getMessage());
System.out.println(ex.getMessage());
}
try {
Iterator<Class<?>> iter = registerclasses.iterator();
while(iter.hasNext()){
Class<?> tempClass = iter.next();
register(tempClass);
}
} catch (Exception e) {
// TODO Auto-generated catch block
GeraLog.error(e.getMessage());
}
register(new ConfigBinder());
LogManager.shutdown();
}
}