Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class BoardRailwayExceptionHandlerFactory extends ExceptionHandlerFactory {
- private ExceptionHandlerFactory exceptionHandlerFactory;
- public BoardRailwayExceptionHandlerFactory(ExceptionHandlerFactory exceptionHandlerFactory) {
- this.exceptionHandlerFactory = exceptionHandlerFactory;
- }
- @Override
- public ExceptionHandler getExceptionHandler() {
- return new BoardRailwayExceptionHandler(exceptionHandlerFactory.getExceptionHandler());
- }
- }
- public class BoardRailwayExceptionHandler extends ExceptionHandlerWrapper {
- private ExceptionHandler exceptionHandler;
- public BoardRailwayExceptionHandler(ExceptionHandler exceptionHandler) {
- this.exceptionHandler = exceptionHandler;
- }
- @Override
- public ExceptionHandler getWrapped() {
- return exceptionHandler;
- }
- @Override
- public void handle() throws FacesException {
- final Iterator<ExceptionQueuedEvent> queue = getUnhandledExceptionQueuedEvents().iterator();
- while (queue.hasNext()) {
- ExceptionQueuedEvent item = queue.next();
- ExceptionQueuedEventContext exceptionQueuedEventContext = (ExceptionQueuedEventContext) item.getSource();
- try {
- Throwable throwable = exceptionQueuedEventContext.getException();
- System.err.println("Exception: " + throwable.getMessage());
- FacesContext context = FacesContext.getCurrentInstance();
- Map<String, Object> requestMap = context.getExternalContext().getRequestMap();
- NavigationHandler nav = context.getApplication().getNavigationHandler();
- requestMap.put("error-message", throwable.getMessage());
- requestMap.put("error-stack", throwable.getStackTrace());
- nav.handleNavigation(context, null, "/error");
- context.renderResponse();
- } finally {
- queue.remove();
- }
- }
- }
- }
- @Singleton
- public class TimeScheduleBean {
- private static final Logger log = Logger.getLogger(TimeScheduleBean.class);
- private DataManager dataManager = DataManager.getInstance();
- private Listener listener = new Listener();
- private Loader loader = Loader.getInstance();
- private List<TimeSchedule> schedulesDeparture;
- private List<TimeSchedule> schedulesArrival;
- private List<Station> stations = loader.getStations();
- private String selectedItem = "Oselki";
- private String lastChangesInfo = "No changes ... ";
- public void update() {
- if (dataManager.getStatusChanges()) {
- lastChangesInfo = dataManager.getLastInfoChanges();
- log.info("update @schedule ... ");
- dataManager.resetStatusChanges();
- /*
- Update schedules for current station if it was updated in real time
- */
- if (dataManager.checkSelectedItem(selectedItem))
- updateSchedules(selectedItem);
- }
- }
- @PostConstruct
- private void init() throws IOException, TimeoutException {
- listener.start();
- updateSchedules(selectedItem);
- }
- @PreDestroy
- private void destroy() throws IOException, TimeoutException {
- listener.stop();
- }
- private void updateSchedules(String selectedItem) {
- schedulesDeparture = dataManager.loadScheduleDeparture(selectedItem);
- schedulesArrival = dataManager.loadScheduleArrival(selectedItem);
- }
- // Getters & setters
- public List<String> getStations() {
- List<String> tokens = new ArrayList<>();
- for (int i = 0; i < stations.size(); i++) {
- tokens.add(stations.get(i).getName());
- }
- return tokens;
- }
- public String getSelectedItem() {
- return selectedItem;
- }
- public String getLastChangesInfo() {
- return lastChangesInfo;
- }
- public List<TimeSchedule> getSchedulesDeparture() {
- return schedulesDeparture;
- }
- public void setSchedulesDeparture(List<TimeSchedule> schedulesDeparture) {
- this.schedulesDeparture = schedulesDeparture;
- }
- public List<TimeSchedule> getSchedulesArrival() {
- return schedulesArrival;
- }
- public void setSchedulesArrival(List<TimeSchedule> schedulesArrival) {
- this.schedulesArrival = schedulesArrival;
- }
- public void setSelectedItem(String selectedItem) {
- this.selectedItem = selectedItem;
- updateSchedules(selectedItem);
- }
- }
- public class Listener {
- private static final String EXCHANGE_NAME = "messages";
- private static final Logger log = Logger.getLogger(Listener.class);
- private Channel channel;
- private Connection connection;
- private DataManager dataManager = DataManager.getInstance();
- public void start() throws IOException, TimeoutException {
- ConnectionFactory connectionFactory = new ConnectionFactory();
- connectionFactory.setHost("localhost");
- connection = connectionFactory.newConnection();
- channel = connection.createChannel();
- channel.queueDeclare(EXCHANGE_NAME, false, false, false, null);
- System.out.println("Receive message");
- Consumer consumer = new DefaultConsumer(channel) {
- @Override
- public void handleDelivery(String consumerTag, Envelope envelope, AMQP.BasicProperties properties, byte[] body)
- throws IOException {
- String message = new String(body, "UTF-8");
- log.info(" [x] Received '" + message + "'");
- if (message.contains("create") || message.contains("delete") || message.contains("update")) {
- log.info(message);
- dataManager.changeState(message);
- }
- }
- };
- channel.basicConsume(EXCHANGE_NAME, true, consumer);
- }
- public void stop() throws IOException, TimeoutException {
- channel.close();
- connection.close();
- }
- }
- 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
- at com.sun.faces.mgbean.BeanBuilder.invokePostConstruct(BeanBuilder.java:227)
- at com.sun.faces.mgbean.BeanBuilder.build(BeanBuilder.java:103)
- at com.sun.faces.mgbean.BeanManager.createAndPush(BeanManager.java:411)
- at com.sun.faces.mgbean.BeanManager.create(BeanManager.java:271)
- at com.sun.faces.el.ManagedBeanELResolver.resolveBean(ManagedBeanELResolver.java:263)
- at com.sun.faces.el.ManagedBeanELResolver.getValue(ManagedBeanELResolver.java:118)
- at com.sun.faces.el.DemuxCompositeELResolver._getValue(DemuxCompositeELResolver.java:180)
- at com.sun.faces.el.DemuxCompositeELResolver.getValue(DemuxCompositeELResolver.java:208)
- at com.sun.el.parser.AstIdentifier.getValue(AstIdentifier.java:116)
- at com.sun.el.parser.AstValue.getBase(AstValue.java:150)
- at com.sun.el.parser.AstValue.getValue(AstValue.java:199)
- at com.sun.el.ValueExpressionImpl.getValue(ValueExpressionImpl.java:226)
- at org.jboss.weld.module.web.el.WeldValueExpression.getValue(WeldValueExpression.java:50)
- at org.jboss.weld.module.web.el.WeldValueExpression.getValue(WeldValueExpression.java:50)
- at com.sun.faces.facelets.el.TagValueExpression.getValue(TagValueExpression.java:115)
- at javax.faces.component.ComponentStateHelper.eval(ComponentStateHelper.java:200)
- at javax.faces.component.ComponentStateHelper.eval(ComponentStateHelper.java:187)
- at javax.faces.component.UIOutput.getValue(UIOutput.java:179)
- at com.sun.faces.renderkit.html_basic.HtmlBasicInputRenderer.getValue(HtmlBasicInputRenderer.java:205)
- at com.sun.faces.renderkit.html_basic.HtmlBasicRenderer.getCurrentValue(HtmlBasicRenderer.java:360)
- at com.sun.faces.renderkit.html_basic.HtmlBasicRenderer.encodeEnd(HtmlBasicRenderer.java:171)
- at javax.faces.component.UIComponentBase.encodeEnd(UIComponentBase.java:949)
- at javax.faces.component.UIComponent.encodeAll(UIComponent.java:1912)
- at javax.faces.render.Renderer.encodeChildren(Renderer.java:176)
- at javax.faces.component.UIComponentBase.encodeChildren(UIComponentBase.java:918)
- at javax.faces.component.UIComponent.encodeAll(UIComponent.java:1905)
- at javax.faces.component.UIComponent.encodeAll(UIComponent.java:1908)
- at javax.faces.component.UIComponent.encodeAll(UIComponent.java:1908)
- at com.sun.faces.application.view.FaceletViewHandlingStrategy.renderView(FaceletViewHandlingStrategy.java:491)
- at com.sun.faces.application.view.MultiViewHandler.renderView(MultiViewHandler.java:194)
- at javax.faces.application.ViewHandlerWrapper.renderView(ViewHandlerWrapper.java:151)
- at javax.faces.application.ViewHandlerWrapper.renderView(ViewHandlerWrapper.java:151)
- at com.sun.faces.lifecycle.RenderResponsePhase.execute(RenderResponsePhase.java:126)
- at com.sun.faces.lifecycle.Phase.doPhase(Phase.java:100)
- at com.sun.faces.lifecycle.LifecycleImpl.render(LifecycleImpl.java:223)
- at javax.faces.webapp.FacesServlet.service(FacesServlet.java:671)
- at io.undertow.servlet.handlers.ServletHandler.handleRequest(ServletHandler.java:74)
- at io.undertow.servlet.handlers.FilterHandler$FilterChainImpl.doFilter(FilterHandler.java:129)
- at io.opentracing.contrib.jaxrs2.server.SpanFinishingFilter.doFilter(SpanFinishingFilter.java:55)
- at io.undertow.servlet.core.ManagedFilter.doFilter(ManagedFilter.java:61)
- at io.undertow.servlet.handlers.FilterHandler$FilterChainImpl.doFilter(FilterHandler.java:131)
- at io.undertow.servlet.handlers.FilterHandler.handleRequest(FilterHandler.java:84)
- at io.undertow.servlet.handlers.security.ServletSecurityRoleHandler.handleRequest(ServletSecurityRoleHandler.java:62)
- at io.undertow.servlet.handlers.ServletChain$1.handleRequest(ServletChain.java:68)
- at io.undertow.servlet.handlers.ServletDispatchingHandler.handleRequest(ServletDispatchingHandler.java:36)
- at org.wildfly.extension.undertow.security.SecurityContextAssociationHandler.handleRequest(SecurityContextAssociationHandler.java:78)
- at io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43)
- at io.undertow.servlet.handlers.security.SSLInformationAssociationHandler.handleRequest(SSLInformationAssociationHandler.java:132)
- at io.undertow.servlet.handlers.security.ServletAuthenticationCallHandler.handleRequest(ServletAuthenticationCallHandler.java:57)
- at io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43)
- at io.undertow.security.handlers.AbstractConfidentialityHandler.handleRequest(AbstractConfidentialityHandler.java:46)
- at io.undertow.servlet.handlers.security.ServletConfidentialityConstraintHandler.handleRequest(ServletConfidentialityConstraintHandler.java:64)
- at io.undertow.security.handlers.AuthenticationMechanismsHandler.handleRequest(AuthenticationMechanismsHandler.java:60)
- at io.undertow.servlet.handlers.security.CachedAuthenticatedSessionHandler.handleRequest(CachedAuthenticatedSessionHandler.java:77)
- at io.undertow.security.handlers.NotificationReceiverHandler.handleRequest(NotificationReceiverHandler.java:50)
- at io.undertow.security.handlers.AbstractSecurityContextAssociationHandler.handleRequest(AbstractSecurityContextAssociationHandler.java:43)
- at io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43)
- at org.wildfly.extension.undertow.security.jacc.JACCContextIdHandler.handleRequest(JACCContextIdHandler.java:61)
- at io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43)
- at org.wildfly.extension.undertow.deployment.GlobalRequestControllerHandler.handleRequest(GlobalRequestControllerHandler.java:68)
- at io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43)
- at io.undertow.servlet.handlers.ServletInitialHandler.handleFirstRequest(ServletInitialHandler.java:292)
- at io.undertow.servlet.handlers.ServletInitialHandler.access$100(ServletInitialHandler.java:81)
- at io.undertow.servlet.handlers.ServletInitialHandler$2.call(ServletInitialHandler.java:138)
- at io.undertow.servlet.handlers.ServletInitialHandler$2.call(ServletInitialHandler.java:135)
- at io.undertow.servlet.core.ServletRequestContextThreadSetupAction$1.call(ServletRequestContextThreadSetupAction.java:48)
- at io.undertow.servlet.core.ContextClassLoaderSetupAction$1.call(ContextClassLoaderSetupAction.java:43)
- at org.wildfly.extension.undertow.security.SecurityContextThreadSetupAction.lambda$create$0(SecurityContextThreadSetupAction.java:105)
- at org.wildfly.extension.undertow.deployment.UndertowDeploymentInfoService$UndertowThreadSetupAction.lambda$create$0(UndertowDeploymentInfoService.java:1502)
- at org.wildfly.extension.undertow.deployment.UndertowDeploymentInfoService$UndertowThreadSetupAction.lambda$create$0(UndertowDeploymentInfoService.java:1502)
- at org.wildfly.extension.undertow.deployment.UndertowDeploymentInfoService$UndertowThreadSetupAction.lambda$create$0(UndertowDeploymentInfoService.java:1502)
- at org.wildfly.extension.undertow.deployment.UndertowDeploymentInfoService$UndertowThreadSetupAction.lambda$create$0(UndertowDeploymentInfoService.java:1502)
- at io.undertow.servlet.handlers.ServletInitialHandler.dispatchRequest(ServletInitialHandler.java:272)
- at io.undertow.servlet.handlers.ServletInitialHandler.access$000(ServletInitialHandler.java:81)
- at io.undertow.servlet.handlers.ServletInitialHandler$1.handleRequest(ServletInitialHandler.java:104)
- at io.undertow.server.Connectors.executeRootHandler(Connectors.java:360)
- at io.undertow.server.HttpServerExchange$1.run(HttpServerExchange.java:830)
- at org.jboss.threads.ContextClassLoaderSavingRunnable.run(ContextClassLoaderSavingRunnable.java:35)
- at org.jboss.threads.EnhancedQueueExecutor.safeRun(EnhancedQueueExecutor.java:1985)
- at org.jboss.threads.EnhancedQueueExecutor$ThreadBody.doRunTask(EnhancedQueueExecutor.java:1487)
- at org.jboss.threads.EnhancedQueueExecutor$ThreadBody.run(EnhancedQueueExecutor.java:1349)
- at java.lang.Thread.run(Thread.java:748)
- Caused by: com.sun.faces.spi.InjectionProviderException: java.lang.IllegalStateException: WFLYEE0042: Failed to construct component instance
- at org.jboss.as.jsf.injection.JSFInjectionProvider.invokePostConstruct(JSFInjectionProvider.java:70)
- at com.sun.faces.mgbean.BeanBuilder.invokePostConstruct(BeanBuilder.java:221)
- ... 81 more
- Caused by: java.lang.IllegalStateException: WFLYEE0042: Failed to construct component instance
- at org.jboss.as.ee.component.BasicComponent.constructComponentInstance(BasicComponent.java:163)
- at org.jboss.as.ee.component.BasicComponent.constructComponentInstance(BasicComponent.java:134)
- at org.jboss.as.ee.component.BasicComponent.createInstance(BasicComponent.java:99)
- at org.jboss.as.ee.component.ComponentRegistry$ComponentManagedReferenceFactory.getReference(ComponentRegistry.java:171)
- at org.jboss.as.ee.component.ComponentRegistry.createInstance(ComponentRegistry.java:87)
- at org.jboss.as.web.common.WebInjectionContainer.newInstance(WebInjectionContainer.java:77)
- at org.jboss.as.jsf.injection.JSFInjectionProvider.invokePostConstruct(JSFInjectionProvider.java:68)
- ... 82 more
- Caused by: java.lang.RuntimeException: WFLYNAM0059: Resource lookup for injection failed: env/com.slandshow.JSF.ScheduleBean/timeScheduleBean
- at org.jboss.as.naming.deployment.ContextNames$BindInfo$1$1.getReference(ContextNames.java:325)
- at org.jboss.as.ee.component.ManagedReferenceFieldInjectionInterceptorFactory$ManagedReferenceFieldInjectionInterceptor.processInvocation(ManagedReferenceFieldInjectionInterceptorFactory.java:97)
- at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:422)
- at org.jboss.as.ee.component.AroundConstructInterceptorFactory$1.processInvocation(AroundConstructInterceptorFactory.java:28)
- at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:422)
- at org.jboss.as.weld.injection.WeldInterceptorInjectionInterceptor.processInvocation(WeldInterceptorInjectionInterceptor.java:56)
- at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:422)
- at org.jboss.as.weld.injection.WeldInjectionContextInterceptor.processInvocation(WeldInjectionContextInterceptor.java:43)
- at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:422)
- at org.jboss.as.ee.concurrent.ConcurrentContextInterceptor.processInvocation(ConcurrentContextInterceptor.java:45)
- at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:422)
- at org.jboss.invocation.ContextClassLoaderInterceptor.processInvocation(ContextClassLoaderInterceptor.java:60)
- at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:422)
- at org.jboss.invocation.ChainedInterceptor.processInvocation(ChainedInterceptor.java:53)
- at org.jboss.as.ee.component.BasicComponent.constructComponentInstance(BasicComponent.java:161)
- ... 88 more
- Caused by: javax.naming.NameNotFoundException: env/com.slandshow.JSF.ScheduleBean/timeScheduleBean [Root exception is java.lang.IllegalStateException: WFLYEE0046: Failed to instantiate component view]
- at org.jboss.as.naming.ServiceBasedNamingStore.lookup(ServiceBasedNamingStore.java:153)
- at org.jboss.as.naming.ServiceBasedNamingStore.lookup(ServiceBasedNamingStore.java:83)
- at org.jboss.as.naming.NamingContext.lookup(NamingContext.java:207)
- at org.jboss.as.naming.NamingContext.lookup(NamingContext.java:193)
- at org.jboss.as.naming.NamingContext.lookup(NamingContext.java:189)
- at org.jboss.as.naming.deployment.ContextNames$BindInfo$1$1.getReference(ContextNames.java:322)
- ... 102 more
- Caused by: java.lang.IllegalStateException: WFLYEE0046: Failed to instantiate component view
- at org.jboss.as.ee.component.ViewManagedReferenceFactory.getReference(ViewManagedReferenceFactory.java:58)
- at org.jboss.as.naming.ServiceBasedNamingStore.lookup(ServiceBasedNamingStore.java:143)
- ... 107 more
- Caused by: com.sun.jersey.api.client.ClientHandlerException: java.net.ConnectException: В соединении отказано (Connection refused)
- at com.sun.jersey.client.urlconnection.URLConnectionClientHandler.handle(URLConnectionClientHandler.java:155)
- at com.sun.jersey.api.client.Client.handle(Client.java:652)
- at com.sun.jersey.api.client.WebResource.handle(WebResource.java:682)
- at com.sun.jersey.api.client.WebResource.access$200(WebResource.java:74)
- at com.sun.jersey.api.client.WebResource$Builder.get(WebResource.java:509)
- at com.slandshow.helpers.Loader.getResultResponse(Loader.java:69)
- at com.slandshow.helpers.Loader.getSchedules(Loader.java:30)
- at com.slandshow.helpers.DataManager.<init>(DataManager.java:16)
- at com.slandshow.helpers.DataManager.getInstance(DataManager.java:72)
- at com.slandshow.service.TimeScheduleBean.<init>(TimeScheduleBean.java:23)
- at com.slandshow.service.TimeScheduleBean$$$view2.<init>(Unknown Source)
- at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
- at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
- at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
- at java.lang.reflect.Constructor.newInstance(Constructor.java:423)
- at java.lang.Class.newInstance(Class.java:442)
- at org.jboss.invocation.proxy.AbstractClassFactory.newInstance(AbstractClassFactory.java:221)
- at org.jboss.invocation.proxy.ProxyFactory.newInstance(ProxyFactory.java:269)
- at org.jboss.as.ee.component.ViewService$DefaultViewInstanceFactory.createViewInstance(ViewService.java:284)
- at org.jboss.as.ee.component.ViewService$View.createInstance(ViewService.java:184)
- at org.jboss.as.ee.component.ViewService$View.createInstance(ViewService.java:174)
- at org.jboss.as.ee.component.ViewManagedReferenceFactory.getReference(ViewManagedReferenceFactory.java:56)
- ... 108 more
- Caused by: java.net.ConnectException: В соединении отказано (Connection refused)
Add Comment
Please, Sign In to add comment