cdi-properties | #JSON Processing | CDI Properties is a CDI extension

 by   gonmarques Java Updated: 2 years ago - 1.1.1 License: Apache-2.0

Download this library from

Build Applications

kandi X-RAY | cdi-properties REVIEW AND RATINGS

CDI Properties is a CDI extension that enables resource bundle injection in a CDI enabled Java EE application, requiring little to no configuration depending on the application requirements. The resource bundle source may be the typical .properties files or any other external resource or system.

kandi-support
Support

  • cdi-properties has a low active ecosystem.
  • It has 24 star(s) with 4 fork(s).
  • It had no major release in the last 12 months.
  • It has a neutral sentiment in the developer community.

quality kandi
Quality

  • cdi-properties has 0 bugs and 0 code smells.

security
Security

  • cdi-properties has no vulnerabilities reported, and its dependent libraries have no vulnerabilities reported.
  • cdi-properties code analysis shows 0 unresolved vulnerabilities.
  • There are 0 security hotspots that need review.

license
License

  • cdi-properties is licensed under the Apache-2.0 License. This license is Permissive.
  • Permissive licenses have the least restrictions, and you can use them in most projects.

build
Reuse

  • cdi-properties releases are available to install and integrate.
  • Deployable package is available in Maven.
  • Build file is available. You can build the component from source.
  • cdi-properties saves you 1469 person hours of effort in developing the same functionality from scratch.
  • It has 3279 lines of code, 265 functions and 112 files with 0 % test coverage
  • It has low code complexity. Code complexity directly impacts maintainability of the code.
Top functions reviewed by kandi - BETA

kandi has reviewed cdi-properties and discovered the below as its top functions. This is intended to give you an instant insight into cdi-properties implemented functionality, and help decide if they suit your requirements.

  • Inject property bundle .
  • Get a converter for the given type .
  • Initialize the resolver .
  • Determines whether a type is dependent on the JEE .
  • Returns the resolver instance .
  • Checks that multiple annotation is annotated .
  • Resolve a property .
  • Initialize the web application context .
  • Gets the qualifiers .
  • Verify that the locale resolver parameter annotation .

cdi-properties Key Features

Java web application

EJB standalone application

cdi-properties examples and code snippets

  • CDI Properties
  • Usage
  • Property Resolver
  • Locale Resolver
  • Configuration

CDI Properties

<dependency>
  <groupId>com.byteslounge</groupId>
  <artifactId>cdi-properties</artifactId>
  <version>1.1.1</version>
</dependency>

Usage

@Property("hello.world")
private String helloWorld;

Property Resolver

@PropertyResolver
public String resolveProperty(@PropertyLocale Locale locale, 
  @PropertyBundle String bundleName, @PropertyKey String key){
  
  String result = // resolve the property;
  return result;
  
}

Locale Resolver

FacesContext.getCurrentInstance().getViewRoot().getLocale();

Configuration

<context-param>
  <description>Default resource bundle name</description>
  <param-name>defaultResourceBundleBaseName</param-name>
  <param-value>com.example.messages</param-value>
</context-param>

COMMUNITY DISCUSSIONS

Top Trending Discussions on cdi-properties
  • FailedToCreateRouteException Deploying Camel-CDI application to Wildfly 8.2
Top Trending Discussions on cdi-properties

QUESTION

FailedToCreateRouteException Deploying Camel-CDI application to Wildfly 8.2

Asked 2017-Mar-31 at 16:03

I am developing an application that reads messages from a Kafka queue, and processes them creating an e-mail and sending it.

I was able to get a simple camel route working in a standalone java application, however when I package it up using CDI and Wildfly 8.2 it fails to deploy. I am following the directions from here: camel CDI Properties example I used the example as a template for my application. I am using Wildfly 8.2.0, Camel 2.18.1, Kafka 0.10.1.1

What am I doing wrong? I don't understand the error "org.apache.camel.FailedToCreateRouteException: Failed to create route Deep-email-notify-route: Route(Deep-email-notify-route)[[From[no uri or ref supplied!... because of Either 'uri' or 'ref' must be specified on: org.apache.camel.impl.DefaultRouteContext@55edcc54"

This is most of my code:

@ApplicationScoped
public class OrderEmailApplication  {

/** The logger. */
private static Logger logger =LogManager.getLogger(OrderEmailRoute.class);

public OrderEmailApplication() {}

@ContextName("OrderNotifications")
static class OrderEmailRoute extends RouteBuilder {

    @Uri("kafka://{{deep.notify.kafka.server}}?topic={{deep.notify.order.topics}}&groupId={{deep.notify.order.groupId}}&"+
                "keyDeserializer=org.apache.kafka.common.serialization.StringDeserializer&" +
                "valueDeserializer=org.apache.kafka.common.serialization.StringDeserializer")
    Endpoint kafkaEndpoint;

    @Uri("file:///home/whomer/tmp/Notify/deadMessages")
    private Endpoint deadLetter;


    @BeanInject
    BulkEmailProcessor bulkEmailProcessor;

    @BeanInject
    FailedMessageEnrichmentProcessor failedEmailEnrichement;


    @Override
    public void configure() throws Exception {
        errorHandler(defaultErrorHandler().maximumRedeliveries(0));

        from(kafkaEndpoint).routeId("Deep-email-notify-route")
        .unmarshal().json(JsonLibrary.Jackson, LinkedHashMap.class)
        .bean("velocityBean")
        .process(bulkEmailProcessor)
        .marshal().json(JsonLibrary.Jackson, Map.class) 
        .to("Log:?level=DEBUG");

        from("direct:getTemplate").to("velocity://dummy");
    }
}

@Named("velocityBean")
static class VelocityBean {
    @Uri("direct:getTemplate")
    private ProducerTemplate template;

    public void process(Exchange exchange) {
        // removed for brevity
    }

}
@Produces
@Named("properties")
// "properties" component bean that Camel uses to lookup properties
PropertiesComponent properties(PropertiesParser parser) {
    PropertiesComponent component = new PropertiesComponent();
    // Use DeltaSpike as configuration source for Camel CDI
    component.setPropertiesParser(parser);
    return component;
}

// PropertiesParser bean that uses DeltaSpike to resolve properties
static class DeltaSpikeParser extends DefaultPropertiesParser {

    @Override
    public String parseProperty(String key, String value, Properties properties) {
        return ConfigResolver.getPropertyValue(key);
    }
}   

}

This is the stack trace:

14:51:37,674 INFO  [org.apache.camel.cdi.CdiCamelExtension] (MSC service thread 1-4) Camel CDI is starting Camel context [OrderNotifications]
14:51:37,680 INFO  [org.apache.camel.impl.DefaultCamelContext] (MSC service thread 1-4) Apache Camel 2.18.1 (CamelContext: OrderNotifications) is starting
14:51:37,682 INFO  [org.apache.camel.management.ManagedManagementStrategy] (MSC service thread 1-4) JMX is enabled
14:51:37,821 INFO  [org.apache.camel.impl.DefaultRuntimeEndpointRegistry] (MSC service thread 1-4) Runtime endpoint registry is in extended mode gathering usage statistics of all incoming and outgoing endpoints (cache limit: 1000)
14:51:37,827 INFO  [org.apache.camel.impl.DefaultCamelContext] (MSC service thread 1-4) Apache Camel 2.18.1 (CamelContext: OrderNotifications) is shutting down
14:51:37,849 INFO  [org.apache.camel.impl.DefaultCamelContext] (MSC service thread 1-4) Apache Camel 2.18.1 (CamelContext: OrderNotifications) uptime 0.169 seconds
14:51:37,849 INFO  [org.apache.camel.impl.DefaultCamelContext] (MSC service thread 1-4) Apache Camel 2.18.1 (CamelContext: OrderNotifications) is shutdown in 0.022 seconds
14:51:37,859 ERROR [org.jboss.msc.service.fail] (MSC service thread 1-4) MSC000001: Failed to start service jboss.deployment.unit."NotificationService.war".WeldStartService: org.jboss.msc.service.StartException in service jboss.deployment.unit."NotificationService.war".WeldStartService: Failed to start service
at org.jboss.msc.service.ServiceControllerImpl$StartTask.run(ServiceControllerImpl.java:1904) [jboss-msc-1.2.2.Final.jar:1.2.2.Final]
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142) [rt.jar:1.8.0_51]
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617) [rt.jar:1.8.0_51]
at java.lang.Thread.run(Thread.java:745) [rt.jar:1.8.0_51]
Caused by: org.jboss.weld.exceptions.DeploymentException: Exception List with 1 exceptions:
Exception 0 :
org.apache.camel.FailedToCreateRouteException: Failed to create route Deep-email-notify-route: Route(Deep-email-notify-route)[[From[no uri or ref supplied!... because of Either 'uri' or 'ref' must be specified on:      org.apache.camel.impl.DefaultRouteContext@55edcc54
at  org.apache.camel.model.RouteDefinition.addRoutes(RouteDefinition.java:201)
at org.apache.camel.impl.DefaultCamelContext.startRoute(DefaultCamelContext.java:1008)
at org.apache.camel.impl.DefaultCamelContext.startRouteDefinitions(DefaultCamelContext.java:3397)
at org.apache.camel.impl.DefaultCamelContext.doStartCamel(DefaultCamelContext.java:3128)
at org.apache.camel.impl.DefaultCamelContext.access$000(DefaultCamelContext.java:182)
at org.apache.camel.impl.DefaultCamelContext$2.call(DefaultCamelContext.java:2957)
at org.apache.camel.impl.DefaultCamelContext$2.call(DefaultCamelContext.java:2953)
at org.apache.camel.impl.DefaultCamelContext.doWithDefinedClassLoader(DefaultCamelContext.java:2976)
at org.apache.camel.impl.DefaultCamelContext.doStart(DefaultCamelContext.java:2953)
at org.apache.camel.support.ServiceSupport.start(ServiceSupport.java:61)
at org.apache.camel.impl.DefaultCamelContext.start(DefaultCamelContext.java:2920)
at org.apache.camel.impl.DefaultCamelContext$Proxy$_$$_WeldClientProxy.start(Unknown Source)
at org.apache.camel.cdi.CdiCamelExtension.afterDeploymentValidation(CdiCamelExtension.java:422)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:497)
at org.jboss.weld.injection.MethodInjectionPoint.invokeOnInstanceWithSpecialValue(MethodInjectionPoint.java:90)
at org.jboss.weld.event.ObserverMethodImpl.sendEvent(ObserverMethodImpl.java:271)
at org.jboss.weld.event.ExtensionObserverMethodImpl.sendEvent(ExtensionObserverMethodImpl.java:121)
at org.jboss.weld.event.ObserverMethodImpl.sendEvent(ObserverMethodImpl.java:258)
at org.jboss.weld.event.ObserverMethodImpl.notify(ObserverMethodImpl.java:237)
at org.jboss.weld.event.ObserverNotifier.notifyObserver(ObserverNotifier.java:174)
at org.jboss.weld.event.ObserverNotifier.notifyObservers(ObserverNotifier.java:133)
at org.jboss.weld.event.ObserverNotifier.fireEvent(ObserverNotifier.java:107)
at org.jboss.weld.bootstrap.events.AbstractContainerEvent.fire(AbstractContainerEvent.java:54)
at org.jboss.weld.bootstrap.events.AbstractDeploymentContainerEvent.fire(AbstractDeploymentContainerEvent.java:35)
at org.jboss.weld.bootstrap.events.AfterDeploymentValidationImpl.fire(AfterDeploymentValidationImpl.java:28)
at org.jboss.weld.bootstrap.WeldStartup.validateBeans(WeldStartup.java:439)
at org.jboss.weld.bootstrap.WeldBootstrap.validateBeans(WeldBootstrap.java:90)
at org.jboss.as.weld.WeldStartService.start(WeldStartService.java:93)
at org.jboss.msc.service.ServiceControllerImpl$StartTask.startService(ServiceControllerImpl.java:1948)
at org.jboss.msc.service.ServiceControllerImpl$StartTask.run(ServiceControllerImpl.java:1881)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
at java.lang.Thread.run(Thread.java:745)
Caused by: java.lang.IllegalArgumentException: Either 'uri' or 'ref' must be specified on: org.apache.camel.impl.DefaultRouteContext@55edcc54
at org.apache.camel.impl.DefaultRouteContext.resolveEndpoint(DefaultRouteContext.java:136)
at org.apache.camel.model.FromDefinition.resolveEndpoint(FromDefinition.java:69)
at org.apache.camel.impl.DefaultRouteContext.getEndpoint(DefaultRouteContext.java:90)
at org.apache.camel.model.RouteDefinition.addRoutes(RouteDefinition.java:1051)
at org.apache.camel.model.RouteDefinition.addRoutes(RouteDefinition.java:196)
... 35 more

at org.jboss.weld.bootstrap.events.AbstractDeploymentContainerEvent.fire(AbstractDeploymentContainerEvent.java:37)
at org.jboss.weld.bootstrap.events.AfterDeploymentValidationImpl.fire(AfterDeploymentValidationImpl.java:28)
at org.jboss.weld.bootstrap.WeldStartup.validateBeans(WeldStartup.java:439)
at org.jboss.weld.bootstrap.WeldBootstrap.validateBeans(WeldBootstrap.java:90)
at org.jboss.as.weld.WeldStartService.start(WeldStartService.java:93)
at org.jboss.msc.service.ServiceControllerImpl$StartTask.startService(ServiceControllerImpl.java:1948) [jboss-msc-1.2.2.Final.jar:1.2.2.Final]
at org.jboss.msc.service.ServiceControllerImpl$StartTask.run(ServiceControllerImpl.java:1881) [jboss-msc-1.2.2.Final.jar:1.2.2.Final]
... 3 more

ANSWER

Answered 2017-Jan-24 at 22:01

OOPS. Programmer error! The main issue turned out to be the Endpoint injections.

Instead of @Uri("kafka:...") Endpoint fubar; the injection should have been:

@EndpointInjection(uri = "kafka:...") Endpoint fubar;

Source https://stackoverflow.com/questions/41839262

Community Discussions, Code Snippets contain sources that include Stack Exchange Network

VULNERABILITIES

No vulnerabilities reported

INSTALL cdi-properties

You can use cdi-properties like any standard Java library. Please include the the jar files in your classpath. You can also use any IDE and you can run and debug the cdi-properties component as you would do with any other Java program. Best practice is to use a build tool that supports dependency management such as Maven or Gradle. For Maven installation, please refer maven.apache.org. For Gradle installation, please refer gradle.org .

SUPPORT

For any new features, suggestions and bugs create an issue on GitHub. If you have any questions check and ask questions on community page Stack Overflow .

Implement cdi-properties faster with kandi.

  • Use the support, quality, security, license, reuse scores and reviewed functions to confirm the fit for your project.
  • Use the, Q & A, Installation and Support guides to implement faster.

Discover Millions of Libraries and
Pre-built Use Cases on kandi