daily pastebin goal
55%
SHARE
TWEET

Untitled

a guest Oct 11th, 2018 82 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. public class BoardRailwayExceptionHandlerFactory extends ExceptionHandlerFactory {
  2.  
  3.     private ExceptionHandlerFactory exceptionHandlerFactory;
  4.  
  5.     public BoardRailwayExceptionHandlerFactory(ExceptionHandlerFactory exceptionHandlerFactory) {
  6.         this.exceptionHandlerFactory = exceptionHandlerFactory;
  7.     }
  8.  
  9.     @Override
  10.     public ExceptionHandler getExceptionHandler() {
  11.         return new BoardRailwayExceptionHandler(exceptionHandlerFactory.getExceptionHandler());
  12.     }
  13. }
  14.  
  15. public class BoardRailwayExceptionHandler extends ExceptionHandlerWrapper {
  16.  
  17.     private ExceptionHandler exceptionHandler;
  18.  
  19.     public BoardRailwayExceptionHandler(ExceptionHandler exceptionHandler) {
  20.         this.exceptionHandler = exceptionHandler;
  21.     }
  22.  
  23.     @Override
  24.     public ExceptionHandler getWrapped() {
  25.         return exceptionHandler;
  26.     }
  27.  
  28.     @Override
  29.     public void handle() throws FacesException {
  30.         final Iterator<ExceptionQueuedEvent> queue = getUnhandledExceptionQueuedEvents().iterator();
  31.  
  32.         while (queue.hasNext()) {
  33.             ExceptionQueuedEvent item = queue.next();
  34.             ExceptionQueuedEventContext exceptionQueuedEventContext = (ExceptionQueuedEventContext) item.getSource();
  35.  
  36.             try {
  37.                 Throwable throwable = exceptionQueuedEventContext.getException();
  38.                 System.err.println("Exception: " + throwable.getMessage());
  39.  
  40.                 FacesContext context = FacesContext.getCurrentInstance();
  41.                 Map<String, Object> requestMap = context.getExternalContext().getRequestMap();
  42.                 NavigationHandler nav = context.getApplication().getNavigationHandler();
  43.  
  44.                 requestMap.put("error-message", throwable.getMessage());
  45.                 requestMap.put("error-stack", throwable.getStackTrace());
  46.                 nav.handleNavigation(context, null, "/error");
  47.                 context.renderResponse();
  48.  
  49.             } finally {
  50.                 queue.remove();
  51.             }
  52.         }
  53.     }
  54. }
  55.    
  56. @Singleton
  57. public class TimeScheduleBean {
  58.  
  59.     private static final Logger log = Logger.getLogger(TimeScheduleBean.class);
  60.  
  61.     private DataManager dataManager = DataManager.getInstance();
  62.     private Listener listener = new Listener();
  63.     private Loader loader = Loader.getInstance();
  64.  
  65.     private List<TimeSchedule> schedulesDeparture;
  66.  
  67.     private List<TimeSchedule> schedulesArrival;
  68.  
  69.     private List<Station> stations = loader.getStations();
  70.  
  71.     private String selectedItem = "Oselki";
  72.  
  73.     private String lastChangesInfo = "No changes ... ";
  74.  
  75.     public void update() {
  76.         if (dataManager.getStatusChanges()) {
  77.             lastChangesInfo = dataManager.getLastInfoChanges();
  78.             log.info("update @schedule ... ");
  79.             dataManager.resetStatusChanges();
  80.  
  81.             /*
  82.             Update schedules for current station if it was updated in real time
  83.              */
  84.  
  85.             if (dataManager.checkSelectedItem(selectedItem))
  86.                 updateSchedules(selectedItem);
  87.         }
  88.     }
  89.  
  90.     @PostConstruct
  91.     private void init() throws IOException, TimeoutException {
  92.         listener.start();
  93.         updateSchedules(selectedItem);
  94.     }
  95.  
  96.     @PreDestroy
  97.     private void destroy() throws IOException, TimeoutException {
  98.         listener.stop();
  99.     }
  100.  
  101.     private void updateSchedules(String selectedItem) {
  102.         schedulesDeparture = dataManager.loadScheduleDeparture(selectedItem);
  103.         schedulesArrival = dataManager.loadScheduleArrival(selectedItem);
  104.     }
  105.  
  106.     // Getters & setters
  107.  
  108.     public List<String> getStations() {
  109.         List<String> tokens = new ArrayList<>();
  110.         for (int i = 0; i < stations.size(); i++) {
  111.             tokens.add(stations.get(i).getName());
  112.         }
  113.         return tokens;
  114.     }
  115.  
  116.     public String getSelectedItem() {
  117.         return selectedItem;
  118.     }
  119.  
  120.     public String getLastChangesInfo() {
  121.         return lastChangesInfo;
  122.     }
  123.  
  124.     public List<TimeSchedule> getSchedulesDeparture() {
  125.         return schedulesDeparture;
  126.     }
  127.  
  128.     public void setSchedulesDeparture(List<TimeSchedule> schedulesDeparture) {
  129.         this.schedulesDeparture = schedulesDeparture;
  130.     }
  131.  
  132.     public List<TimeSchedule> getSchedulesArrival() {
  133.         return schedulesArrival;
  134.     }
  135.  
  136.     public void setSchedulesArrival(List<TimeSchedule> schedulesArrival) {
  137.         this.schedulesArrival = schedulesArrival;
  138.     }
  139.  
  140.     public void setSelectedItem(String selectedItem) {
  141.         this.selectedItem = selectedItem;
  142.  
  143.         updateSchedules(selectedItem);
  144.     }
  145.  
  146.  
  147. }
  148.    
  149. public class Listener {
  150.  
  151.     private static final String EXCHANGE_NAME = "messages";
  152.     private static final Logger log = Logger.getLogger(Listener.class);
  153.     private Channel channel;
  154.     private Connection connection;
  155.     private DataManager dataManager = DataManager.getInstance();
  156.  
  157.     public void start() throws IOException, TimeoutException {
  158.         ConnectionFactory connectionFactory = new ConnectionFactory();
  159.         connectionFactory.setHost("localhost");
  160.         connection = connectionFactory.newConnection();
  161.         channel = connection.createChannel();
  162.         channel.queueDeclare(EXCHANGE_NAME, false, false, false, null);
  163.         System.out.println("Receive message");
  164.         Consumer consumer = new DefaultConsumer(channel) {
  165.             @Override
  166.             public void handleDelivery(String consumerTag, Envelope envelope, AMQP.BasicProperties properties, byte[] body)
  167.                     throws IOException {
  168.                 String message = new String(body, "UTF-8");
  169.                 log.info(" [x] Received '" + message + "'");
  170.                 if (message.contains("create") || message.contains("delete") || message.contains("update")) {
  171.                     log.info(message);
  172.                     dataManager.changeState(message);
  173.                 }
  174.             }
  175.         };
  176.         channel.basicConsume(EXCHANGE_NAME, true, consumer);
  177.     }
  178.  
  179.     public void stop() throws IOException, TimeoutException {
  180.         channel.close();
  181.         connection.close();
  182.     }
  183.  
  184. }
  185.    
  186. 22:44:36,885 SEVERE [javax.enterprise.resource.webcontainer.jsf.application] (default task-1) Error Rendering View[/home.xhtml]: com.sun.faces.mgbean.ManagedBeanCreationException: An error occurred performing resource injection on managed bean scheduleBean
  187.     at com.sun.faces.mgbean.BeanBuilder.invokePostConstruct(BeanBuilder.java:227)
  188.     at com.sun.faces.mgbean.BeanBuilder.build(BeanBuilder.java:103)
  189.     at com.sun.faces.mgbean.BeanManager.createAndPush(BeanManager.java:411)
  190.     at com.sun.faces.mgbean.BeanManager.create(BeanManager.java:271)
  191.     at com.sun.faces.el.ManagedBeanELResolver.resolveBean(ManagedBeanELResolver.java:263)
  192.     at com.sun.faces.el.ManagedBeanELResolver.getValue(ManagedBeanELResolver.java:118)
  193.     at com.sun.faces.el.DemuxCompositeELResolver._getValue(DemuxCompositeELResolver.java:180)
  194.     at com.sun.faces.el.DemuxCompositeELResolver.getValue(DemuxCompositeELResolver.java:208)
  195.     at com.sun.el.parser.AstIdentifier.getValue(AstIdentifier.java:116)
  196.     at com.sun.el.parser.AstValue.getBase(AstValue.java:150)
  197.     at com.sun.el.parser.AstValue.getValue(AstValue.java:199)
  198.     at com.sun.el.ValueExpressionImpl.getValue(ValueExpressionImpl.java:226)
  199.     at org.jboss.weld.module.web.el.WeldValueExpression.getValue(WeldValueExpression.java:50)
  200.     at org.jboss.weld.module.web.el.WeldValueExpression.getValue(WeldValueExpression.java:50)
  201.     at com.sun.faces.facelets.el.TagValueExpression.getValue(TagValueExpression.java:115)
  202.     at javax.faces.component.ComponentStateHelper.eval(ComponentStateHelper.java:200)
  203.     at javax.faces.component.ComponentStateHelper.eval(ComponentStateHelper.java:187)
  204.     at javax.faces.component.UIOutput.getValue(UIOutput.java:179)
  205.     at com.sun.faces.renderkit.html_basic.HtmlBasicInputRenderer.getValue(HtmlBasicInputRenderer.java:205)
  206.     at com.sun.faces.renderkit.html_basic.HtmlBasicRenderer.getCurrentValue(HtmlBasicRenderer.java:360)
  207.     at com.sun.faces.renderkit.html_basic.HtmlBasicRenderer.encodeEnd(HtmlBasicRenderer.java:171)
  208.     at javax.faces.component.UIComponentBase.encodeEnd(UIComponentBase.java:949)
  209.     at javax.faces.component.UIComponent.encodeAll(UIComponent.java:1912)
  210.     at javax.faces.render.Renderer.encodeChildren(Renderer.java:176)
  211.     at javax.faces.component.UIComponentBase.encodeChildren(UIComponentBase.java:918)
  212.     at javax.faces.component.UIComponent.encodeAll(UIComponent.java:1905)
  213.     at javax.faces.component.UIComponent.encodeAll(UIComponent.java:1908)
  214.     at javax.faces.component.UIComponent.encodeAll(UIComponent.java:1908)
  215.     at com.sun.faces.application.view.FaceletViewHandlingStrategy.renderView(FaceletViewHandlingStrategy.java:491)
  216.     at com.sun.faces.application.view.MultiViewHandler.renderView(MultiViewHandler.java:194)
  217.     at javax.faces.application.ViewHandlerWrapper.renderView(ViewHandlerWrapper.java:151)
  218.     at javax.faces.application.ViewHandlerWrapper.renderView(ViewHandlerWrapper.java:151)
  219.     at com.sun.faces.lifecycle.RenderResponsePhase.execute(RenderResponsePhase.java:126)
  220.     at com.sun.faces.lifecycle.Phase.doPhase(Phase.java:100)
  221.     at com.sun.faces.lifecycle.LifecycleImpl.render(LifecycleImpl.java:223)
  222.     at javax.faces.webapp.FacesServlet.service(FacesServlet.java:671)
  223.     at io.undertow.servlet.handlers.ServletHandler.handleRequest(ServletHandler.java:74)
  224.     at io.undertow.servlet.handlers.FilterHandler$FilterChainImpl.doFilter(FilterHandler.java:129)
  225.     at io.opentracing.contrib.jaxrs2.server.SpanFinishingFilter.doFilter(SpanFinishingFilter.java:55)
  226.     at io.undertow.servlet.core.ManagedFilter.doFilter(ManagedFilter.java:61)
  227.     at io.undertow.servlet.handlers.FilterHandler$FilterChainImpl.doFilter(FilterHandler.java:131)
  228.     at io.undertow.servlet.handlers.FilterHandler.handleRequest(FilterHandler.java:84)
  229.     at io.undertow.servlet.handlers.security.ServletSecurityRoleHandler.handleRequest(ServletSecurityRoleHandler.java:62)
  230.     at io.undertow.servlet.handlers.ServletChain$1.handleRequest(ServletChain.java:68)
  231.     at io.undertow.servlet.handlers.ServletDispatchingHandler.handleRequest(ServletDispatchingHandler.java:36)
  232.     at org.wildfly.extension.undertow.security.SecurityContextAssociationHandler.handleRequest(SecurityContextAssociationHandler.java:78)
  233.     at io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43)
  234.     at io.undertow.servlet.handlers.security.SSLInformationAssociationHandler.handleRequest(SSLInformationAssociationHandler.java:132)
  235.     at io.undertow.servlet.handlers.security.ServletAuthenticationCallHandler.handleRequest(ServletAuthenticationCallHandler.java:57)
  236.     at io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43)
  237.     at io.undertow.security.handlers.AbstractConfidentialityHandler.handleRequest(AbstractConfidentialityHandler.java:46)
  238.     at io.undertow.servlet.handlers.security.ServletConfidentialityConstraintHandler.handleRequest(ServletConfidentialityConstraintHandler.java:64)
  239.     at io.undertow.security.handlers.AuthenticationMechanismsHandler.handleRequest(AuthenticationMechanismsHandler.java:60)
  240.     at io.undertow.servlet.handlers.security.CachedAuthenticatedSessionHandler.handleRequest(CachedAuthenticatedSessionHandler.java:77)
  241.     at io.undertow.security.handlers.NotificationReceiverHandler.handleRequest(NotificationReceiverHandler.java:50)
  242.     at io.undertow.security.handlers.AbstractSecurityContextAssociationHandler.handleRequest(AbstractSecurityContextAssociationHandler.java:43)
  243.     at io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43)
  244.     at org.wildfly.extension.undertow.security.jacc.JACCContextIdHandler.handleRequest(JACCContextIdHandler.java:61)
  245.     at io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43)
  246.     at org.wildfly.extension.undertow.deployment.GlobalRequestControllerHandler.handleRequest(GlobalRequestControllerHandler.java:68)
  247.     at io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43)
  248.     at io.undertow.servlet.handlers.ServletInitialHandler.handleFirstRequest(ServletInitialHandler.java:292)
  249.     at io.undertow.servlet.handlers.ServletInitialHandler.access$100(ServletInitialHandler.java:81)
  250.     at io.undertow.servlet.handlers.ServletInitialHandler$2.call(ServletInitialHandler.java:138)
  251.     at io.undertow.servlet.handlers.ServletInitialHandler$2.call(ServletInitialHandler.java:135)
  252.     at io.undertow.servlet.core.ServletRequestContextThreadSetupAction$1.call(ServletRequestContextThreadSetupAction.java:48)
  253.     at io.undertow.servlet.core.ContextClassLoaderSetupAction$1.call(ContextClassLoaderSetupAction.java:43)
  254.     at org.wildfly.extension.undertow.security.SecurityContextThreadSetupAction.lambda$create$0(SecurityContextThreadSetupAction.java:105)
  255.     at org.wildfly.extension.undertow.deployment.UndertowDeploymentInfoService$UndertowThreadSetupAction.lambda$create$0(UndertowDeploymentInfoService.java:1502)
  256.     at org.wildfly.extension.undertow.deployment.UndertowDeploymentInfoService$UndertowThreadSetupAction.lambda$create$0(UndertowDeploymentInfoService.java:1502)
  257.     at org.wildfly.extension.undertow.deployment.UndertowDeploymentInfoService$UndertowThreadSetupAction.lambda$create$0(UndertowDeploymentInfoService.java:1502)
  258.     at org.wildfly.extension.undertow.deployment.UndertowDeploymentInfoService$UndertowThreadSetupAction.lambda$create$0(UndertowDeploymentInfoService.java:1502)
  259.     at io.undertow.servlet.handlers.ServletInitialHandler.dispatchRequest(ServletInitialHandler.java:272)
  260.     at io.undertow.servlet.handlers.ServletInitialHandler.access$000(ServletInitialHandler.java:81)
  261.     at io.undertow.servlet.handlers.ServletInitialHandler$1.handleRequest(ServletInitialHandler.java:104)
  262.     at io.undertow.server.Connectors.executeRootHandler(Connectors.java:360)
  263.     at io.undertow.server.HttpServerExchange$1.run(HttpServerExchange.java:830)
  264.     at org.jboss.threads.ContextClassLoaderSavingRunnable.run(ContextClassLoaderSavingRunnable.java:35)
  265.     at org.jboss.threads.EnhancedQueueExecutor.safeRun(EnhancedQueueExecutor.java:1985)
  266.     at org.jboss.threads.EnhancedQueueExecutor$ThreadBody.doRunTask(EnhancedQueueExecutor.java:1487)
  267.     at org.jboss.threads.EnhancedQueueExecutor$ThreadBody.run(EnhancedQueueExecutor.java:1349)
  268.     at java.lang.Thread.run(Thread.java:748)
  269. Caused by: com.sun.faces.spi.InjectionProviderException: java.lang.IllegalStateException: WFLYEE0042: Failed to construct component instance
  270.     at org.jboss.as.jsf.injection.JSFInjectionProvider.invokePostConstruct(JSFInjectionProvider.java:70)
  271.     at com.sun.faces.mgbean.BeanBuilder.invokePostConstruct(BeanBuilder.java:221)
  272.     ... 81 more
  273. Caused by: java.lang.IllegalStateException: WFLYEE0042: Failed to construct component instance
  274.     at org.jboss.as.ee.component.BasicComponent.constructComponentInstance(BasicComponent.java:163)
  275.     at org.jboss.as.ee.component.BasicComponent.constructComponentInstance(BasicComponent.java:134)
  276.     at org.jboss.as.ee.component.BasicComponent.createInstance(BasicComponent.java:99)
  277.     at org.jboss.as.ee.component.ComponentRegistry$ComponentManagedReferenceFactory.getReference(ComponentRegistry.java:171)
  278.     at org.jboss.as.ee.component.ComponentRegistry.createInstance(ComponentRegistry.java:87)
  279.     at org.jboss.as.web.common.WebInjectionContainer.newInstance(WebInjectionContainer.java:77)
  280.     at org.jboss.as.jsf.injection.JSFInjectionProvider.invokePostConstruct(JSFInjectionProvider.java:68)
  281.     ... 82 more
  282. Caused by: java.lang.RuntimeException: WFLYNAM0059: Resource lookup for injection failed: env/com.slandshow.JSF.ScheduleBean/timeScheduleBean
  283.     at org.jboss.as.naming.deployment.ContextNames$BindInfo$1$1.getReference(ContextNames.java:325)
  284.     at org.jboss.as.ee.component.ManagedReferenceFieldInjectionInterceptorFactory$ManagedReferenceFieldInjectionInterceptor.processInvocation(ManagedReferenceFieldInjectionInterceptorFactory.java:97)
  285.     at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:422)
  286.     at org.jboss.as.ee.component.AroundConstructInterceptorFactory$1.processInvocation(AroundConstructInterceptorFactory.java:28)
  287.     at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:422)
  288.     at org.jboss.as.weld.injection.WeldInterceptorInjectionInterceptor.processInvocation(WeldInterceptorInjectionInterceptor.java:56)
  289.     at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:422)
  290.     at org.jboss.as.weld.injection.WeldInjectionContextInterceptor.processInvocation(WeldInjectionContextInterceptor.java:43)
  291.     at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:422)
  292.     at org.jboss.as.ee.concurrent.ConcurrentContextInterceptor.processInvocation(ConcurrentContextInterceptor.java:45)
  293.     at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:422)
  294.     at org.jboss.invocation.ContextClassLoaderInterceptor.processInvocation(ContextClassLoaderInterceptor.java:60)
  295.     at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:422)
  296.     at org.jboss.invocation.ChainedInterceptor.processInvocation(ChainedInterceptor.java:53)
  297.     at org.jboss.as.ee.component.BasicComponent.constructComponentInstance(BasicComponent.java:161)
  298.     ... 88 more
  299. Caused by: javax.naming.NameNotFoundException: env/com.slandshow.JSF.ScheduleBean/timeScheduleBean [Root exception is java.lang.IllegalStateException: WFLYEE0046: Failed to instantiate component view]
  300.     at org.jboss.as.naming.ServiceBasedNamingStore.lookup(ServiceBasedNamingStore.java:153)
  301.     at org.jboss.as.naming.ServiceBasedNamingStore.lookup(ServiceBasedNamingStore.java:83)
  302.     at org.jboss.as.naming.NamingContext.lookup(NamingContext.java:207)
  303.     at org.jboss.as.naming.NamingContext.lookup(NamingContext.java:193)
  304.     at org.jboss.as.naming.NamingContext.lookup(NamingContext.java:189)
  305.     at org.jboss.as.naming.deployment.ContextNames$BindInfo$1$1.getReference(ContextNames.java:322)
  306.     ... 102 more
  307. Caused by: java.lang.IllegalStateException: WFLYEE0046: Failed to instantiate component view
  308.     at org.jboss.as.ee.component.ViewManagedReferenceFactory.getReference(ViewManagedReferenceFactory.java:58)
  309.     at org.jboss.as.naming.ServiceBasedNamingStore.lookup(ServiceBasedNamingStore.java:143)
  310.     ... 107 more
  311. Caused by: com.sun.jersey.api.client.ClientHandlerException: java.net.ConnectException: В соединении отказано (Connection refused)
  312.     at com.sun.jersey.client.urlconnection.URLConnectionClientHandler.handle(URLConnectionClientHandler.java:155)
  313.     at com.sun.jersey.api.client.Client.handle(Client.java:652)
  314.     at com.sun.jersey.api.client.WebResource.handle(WebResource.java:682)
  315.     at com.sun.jersey.api.client.WebResource.access$200(WebResource.java:74)
  316.     at com.sun.jersey.api.client.WebResource$Builder.get(WebResource.java:509)
  317.     at com.slandshow.helpers.Loader.getResultResponse(Loader.java:69)
  318.     at com.slandshow.helpers.Loader.getSchedules(Loader.java:30)
  319.     at com.slandshow.helpers.DataManager.<init>(DataManager.java:16)
  320.     at com.slandshow.helpers.DataManager.getInstance(DataManager.java:72)
  321.     at com.slandshow.service.TimeScheduleBean.<init>(TimeScheduleBean.java:23)
  322.     at com.slandshow.service.TimeScheduleBean$$$view2.<init>(Unknown Source)
  323.     at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
  324.     at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
  325.     at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
  326.     at java.lang.reflect.Constructor.newInstance(Constructor.java:423)
  327.     at java.lang.Class.newInstance(Class.java:442)
  328.     at org.jboss.invocation.proxy.AbstractClassFactory.newInstance(AbstractClassFactory.java:221)
  329.     at org.jboss.invocation.proxy.ProxyFactory.newInstance(ProxyFactory.java:269)
  330.     at org.jboss.as.ee.component.ViewService$DefaultViewInstanceFactory.createViewInstance(ViewService.java:284)
  331.     at org.jboss.as.ee.component.ViewService$View.createInstance(ViewService.java:184)
  332.     at org.jboss.as.ee.component.ViewService$View.createInstance(ViewService.java:174)
  333.     at org.jboss.as.ee.component.ViewManagedReferenceFactory.getReference(ViewManagedReferenceFactory.java:56)
  334.     ... 108 more
  335. Caused by: java.net.ConnectException: В соединении отказано (Connection refused)
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top