I am new to Apache camel and quartz scheduler. I am trying to to use them both in integration but unable to do it. I found a little article in "Camel in Action" book but I didn't manage to run the program also- here is my code
package com.cockpitconfig.schedulars;
import org.apache.camel.CamelContext;
import org.apache.camel.builder.RouteBuilder;
import org.apache.camel.impl.DefaultCamelContext;
public class TestScheduler {
public static void main(String args[]) throws Exception {
CamelContext context = new DefaultCamelContext();
context.disableJMX();
context.addRoutes(new RouteBuilder() {
#Override
public void configure() {
from(
"quartz://myTimer?trigger.repeatInterval=2000&trigger.repeatCount=-1")
.setBody().simple("Current time is ").to("stream:out");
}
});
context.start();
Thread.sleep(10000);
context.stop();
}
}
But it is giving error
Exception in thread "main" java.lang.InstantiationError: org.quartz.SimpleTrigger
at org.apache.camel.component.quartz.QuartzComponent.createEndpoint(QuartzComponent.java:119)
at org.apache.camel.component.quartz.QuartzComponent.createEndpoint(QuartzComponent.java:54)
at org.apache.camel.impl.DefaultComponent.createEndpoint(DefaultComponent.java:75)
at org.apache.camel.impl.DefaultCamelContext.getEndpoint(DefaultCamelContext.java:419)
at org.apache.camel.util.CamelContextHelper.getMandatoryEndpoint(CamelContextHelper.java:47)
at org.apache.camel.model.RouteDefinition.resolveEndpoint(RouteDefinition.java:189)
at org.apache.camel.impl.DefaultRouteContext.resolveEndpoint(DefaultRouteContext.java:110)
at org.apache.camel.impl.DefaultRouteContext.resolveEndpoint(DefaultRouteContext.java:116)
at org.apache.camel.model.FromDefinition.resolveEndpoint(FromDefinition.java:73)
at org.apache.camel.impl.DefaultRouteContext.getEndpoint(DefaultRouteContext.java:88)
at org.apache.camel.model.RouteDefinition.addRoutes(RouteDefinition.java:751)
at org.apache.camel.model.RouteDefinition.addRoutes(RouteDefinition.java:174)
at org.apache.camel.impl.DefaultCamelContext.startRoute(DefaultCamelContext.java:610)
at org.apache.camel.impl.DefaultCamelContext.startRouteDefinitions(DefaultCamelContext.java:1514)
at org.apache.camel.impl.DefaultCamelContext.doStartCamel(DefaultCamelContext.java:1306)
at org.apache.camel.impl.DefaultCamelContext.doStart(DefaultCamelContext.java:1213)
at org.apache.camel.impl.ServiceSupport.start(ServiceSupport.java:65)
at org.apache.camel.impl.ServiceSupport.start(ServiceSupport.java:52)
at org.apache.camel.impl.DefaultCamelContext.start(DefaultCamelContext.java:1191)
at com.cockpitconfig.schedulars.TestScheduler.main(TestScheduler.java:24)
Does anybody have solution to this problem?
what version of Camel are you using? it worked fine for me using 2.8-SNAPSHOT. just make sure you have camel-core, camel-quartz and camel-stream dependencies in your path.
It's not obvious from the current camel-quartz plugin docs, but as of Camel 2.11.0 it is only compatible with Quartz 1.x and is NOT compatible with Quartz 2.x (which has been out for a couple of years now) because Quartz 2.x is not compatible with Spring 3.0 (and Camel has said that it will maintain Spring 3.0 compatibility for now.
This is documented on this Camel JIRA issue.
Related
Now I'm trying to create Message Service function with kafka to use spring-cloud-stream-bind-kafka, but didn't work so well.
Configuration:
spring boot 1.4.2
build.gradle:
compile "org.springframework.cloud:spring-cloud-stream:2.0.1.RELEASE"
compile "org.springframework.cloud:spring-cloud-stream-binder-kafka:2.0.1.RELEASE"
code:
#EnableBindings(MessagePublish.class)
class MessageConfiguration {
}
interface MessagePublish {
#Output("test")
MessageChannel publish();
}
class TestService {
#Autowired
MessagePublish messagePublish;
public void doSomething() {
// do something
messagePublish.publish().send(MessageBuilder.withPayload("test").build());
}
}
It failed when I start the project with this error log
Caused by: org.springframework.boot.autoconfigure.condition.OnBeanCondition$BeanTypeDeductionException: Failed to deduce bean type for org.springframework.cloud.stream.config.BindingServiceConfiguration.bindingService
....
Caused by: java.lang.ClassNotFoundException: org.springframework.integration.support.converter.ConfigurableCompositeMessageConverter
I'm suspecting my spring boot version. It's so low version.
I think spring-cloud-stream-binder-kafka can't be used under spring boot 2.0 version or other reasons.
I don't know how can I do and how can I explore this situation...
If you give me a little advice, I really appreciate you.
If you are using Spring Boot 1.4.x version then you should use the Spring Cloud Camden release train.
https://github.com/spring-projects/spring-cloud/wiki/Spring-Cloud-Camden-Release-Notes
In particular, you should use the following versions:
compile "org.springframework.cloud:spring-cloud-stream:1.1.2.RELEASE"
compile "org.springframework.cloud:spring-cloud-stream-binder-kafka:1.1.2.RELEASE"
I am new to Infinispan and JBOSS Cache, and am trying to learn these concepts using infinispan documentation. But was not successful in configuring custom xml configuration for cache. Can you please help me out ??
I have following Java Class (Infinispan jar files added to build path)
CustomCacheBean.java
package com.jboss.cache;
import java.io.IOException;
import org.infinispan.Cache;
import org.infinispan.configuration.cache.ConfigurationBuilder;
import org.infinispan.eviction.EvictionStrategy;
import org.infinispan.manager.DefaultCacheManager;
import org.infinispan.manager.EmbeddedCacheManager;
public class CustomCacheBean {
public static void main(String[] args) {
EmbeddedCacheManager manager =
new DefaultCacheManager();
manager.defineConfiguration("custom-cache",new ConfigurationBuilder().build());
Cache<Object, Object> c = manager.getCache("custom-cache");
try {
c = new DefaultCacheManager("infinispan.xml").getCache("xml-configured-cache");
} catch (IOException e) {
e.printStackTrace();
}
}
}
And following is my xml
infinispan.xml (placed under web_Content folder)
<infinispan xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="urn:infinispan:config:8.0.1 http://www.infinispan.org/schemas/infinispan-config-8.0.1.xsd"
xmlns="urn:infinispan:config:8.0.1">
<namedCache name="xml-configured-cache">
<eviction strategy="LIRS" maxEntries="10" />
</namedCache>
</infinispan>
When I try to execute CustomCacheBean java class, I am getting following error
Console :
log4j:WARN No appenders could be found for logger (infinispan.org.jboss.logging).
log4j:WARN Please initialize the log4j system properly.
Exception in thread "main" org.infinispan.commons.CacheConfigurationException: ISPN000327: Cannot find a parser for element 'infinispan' in namespace
'urn:infinispan:config:8.0.1'. Check that your configuration is up-to date for this version of Infinispan.
at org.infinispan.configuration.parsing.ParserRegistry.parseElement(ParserRegistry.java:147)
at org.infinispan.configuration.parsing.ParserRegistry.parse(ParserRegistry.java:131)
at org.infinispan.configuration.parsing.ParserRegistry.parse(ParserRegistry.java:118)
at org.infinispan.configuration.parsing.ParserRegistry.parse(ParserRegistry.java:105)
at org.infinispan.manager.DefaultCacheManager.<init>(DefaultCacheManager.java:271)
at org.infinispan.manager.DefaultCacheManager.<init>(DefaultCacheManager.java:244)
at org.infinispan.manager.DefaultCacheManager.<init>(DefaultCacheManager.java:231)
at com.jboss.cache.CustomCacheBean.main(CustomCacheBean.java:19)
I would recommend using Java based configuration instead of XML. You may take a look at tutorials:
Tutorials page
Distributed Cache (which is probably what you will need)
Please note there is a Github button at the bottom of the page (which will navigate you to the Github repository).
You're probably using wrong namespace in the XML config - namespaces don't use micro version, therefore, use:
xsi:schemaLocation="urn:infinispan:config:8.0 http://www.infinispan.org/schemas/infinispan-config-8.0.xsd" xmlns="urn:infinispan:config:8.0"
instead of
xsi:schemaLocation="urn:infinispan:config:8.0.1 http://www.infinispan.org/schemas/infinispan-config-8.0.1.xsd" xmlns="urn:infinispan:config:8.0.1"
Please, make sure that your IDE validates your configuration against the XSD; this can save you a lot of fuss (not only with Infinispan).
For a variety of reasons, I ended up using spring boot 1.2.0 RC2.
So a spring data mongo application that worked fine in spring boot1.1.8 is now having issues. No code was changed except for the bump to spring boot 1.2.0 RC2. This is due to the snapshot version of spring cloud moving to this spring boot version.
The repository class is as follows
#Repository
public interface OAuth2AccessTokenRepository extends MongoRepository<OAuth2AuthenticationAccessToken, String> {
public OAuth2AuthenticationAccessToken findByTokenId(String tokenId);
public OAuth2AuthenticationAccessToken findByRefreshToken(String refreshToken);
public OAuth2AuthenticationAccessToken findByAuthenticationId(String authenticationId);
public List<OAuth2AuthenticationAccessToken> findByClientIdAndUserName(String clientId, String userName);
public List<OAuth2AuthenticationAccessToken> findByClientId(String clientId);
}
This worked quite well before the bump in versions and now I see this in the log.
19:04:35.510 [main] DEBUG o.s.c.a.ClassPathBeanDefinitionScanner - Ignored because not a concrete top-level class: file [/Users/larrymitchell/rpilprojects/corerpilservicescomponents/channelMap/target/classes/com/cisco/services/rpil/mongo/repository/oauth2/OAuth2AccessTokenRepository.class]
I do have another mongo repository that is recognized but it was defined as a class implementation
#Component
public class ChannelMapRepository { ... }
This one is recognized (I defined it as a implementation class as a workaround for another problem I had). This class is recognized and seems to work fine.
19:04:35.513 [main] DEBUG o.s.c.a.ClassPathBeanDefinitionScanner - Identified candidate component class: file [/Users/larrymitchell/rpilprojects/corerpilservicescomponents/channelMap/target/classes/com/cisco/services/rpil/services/Microservice.class]
Anyone have an idea why? I looked up the various reasons for why component scanning would not work and nothing lends itself to my issue.
Try removing the #Repository annotation? Worked for me. This was an issue in Github as well.
I've followed the instructions here to create a client to a remote SessionBean. I run the client on the same machine that Glassfish 3.1.2 beta is running on. When I use the gf-client.jar from the 3.1.2 beta Glassfish I get the following Exception which is the same Exception if I leave the gf-client.jar out of the classpath:
javax.naming.NoInitialContextException: Need to specify class name in environment or system property, or as an applet parameter, or in an application resource file: java.naming.factory.initial
If I use a 3.1.1 gf-client.jar from a Maven repository I get a huge stack trace with complaints about it not being able to find some .jar files from Derby which I'm not even using. Apparently a version mismatch problem.
Has anyone gotten a standalone client to connect to Glassfish 3.1.2 beta? Did this change in JavaEE 6?
Here's the code:
#Stateless
public class LockTestDeadlockService implements LockTestDeadlockServiceI {
public int getP1Id() throws SQLException {
int parentId = -1;
return parentId;
}
}
#Remote
public interface LockTestDeadlockServiceI {
public int getP1Id() throws SQLException;
public void insertChildUpdateParent(int parentId) throws SQLException;
}
Here's my client:
public class LoadTestClient {
static Logger logger = Logger.getLogger(LoadTestClient.class);
public static void main(String[] args) {
String jndiName = "java:global/locktest-0.0.1-SNAPSHOT/LockTestDeadlockService";
try {
LockTestDeadlockServiceI lockTestService =
(LockTestDeadlockServiceI) new InitialContext().lookup(jndiName);
logger.info("Got lockTestService Remote Interface");
} catch (NamingException e) {
logger.info("Failed to get lockTestService Remote Interface: " + e);
}
}
}
The short answer is that to connect to GF 3.x from a client, you need a mini-glassfish install via the Application Client Container (ACC) using either webstart or the package-appclient script. Open up the gf-client.jar and look at its classpath in the manifest file. There are a ton of files listed in there. This was similar in GF 2.x, but it seemed to need less dependencies on the client (though it was 15MB with that version).
See these:
Create an "Application Client" with Maven in Java EE
With which maven dependencies can i create a standalone JMS client for Glassfish?
http://docs.oracle.com/cd/E18930_01/html/821-2418/beakt.html#scrolltoc
http://docs.oracle.com/cd/E18930_01/html/821-2418/beakv.html#beakz
First of all, I'd like to underline that I've already read other posts in StackOverflow (example) with similar questions, but unfortunately I didn't manage to solve this problem with the answers I saw on those posts. I have no intention to repost a question that has already been answered, so if that's the case, I apologize and I'd be thankful to whom points out where the solution is posted.
Here is my question:
I'm trying to deploy an EJB in WebLogic 10.3.2. The purpose is to use a specific WorkManager to execute work produced in the scope of this component.
With this in mind, I've set up a WorkManager (named ResponseTimeReqClass-0) on my WebLogic configuration, using the web-based interface (Environment > Work Managers > New). Here is a screenshot:
Here is my session bean definition and descriptors:
OrquestratorRemote.java
package orquestrator;
import javax.ejb.Remote;
#Remote
public interface OrquestratorRemote {
public void initOrquestrator();
}
OrquestratorBean.java
package orquestrator;
import javax.ejb.Stateless;
import com.siemens.ecustoms.orchestration.eCustomsOrchestrator;
#Stateless(name = "OrquestratorBean", mappedName = "OrquestratorBean")
public class OrquestratorBean implements OrquestratorRemote {
public void initOrquestrator(){
eCustomsOrchestrator orquestrator = new eCustomsOrchestrator();
orquestrator.run();
}
}
META-INF\ejb-jar.xml
<?xml version='1.0' encoding='UTF-8'?>
<ejb-jar xmlns='http://java.sun.com/xml/ns/javaee'
xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance'
metadata-complete='true'>
<enterprise-beans>
<session>
<ejb-name>OrquestradorEJB</ejb-name>
<mapped-name>OrquestratorBean</mapped-name>
<business-remote>orquestrator.OrquestratorRemote</business-remote>
<ejb-class>orquestrator.OrquestratorBean</ejb-class>
<session-type>Stateless</session-type>
<transaction-type>Container</transaction-type>
</session>
</enterprise-beans>
<assembly-descriptor></assembly-descriptor>
</ejb-jar>
META-INF\weblogic-ejb-jar.xml
(I've placed work manager configuration in this file, as I've seen on a tutorial on the internet)
<weblogic-ejb-jar xmlns="http://www.bea.com/ns/weblogic/90"
xmlns:j2ee="http://java.sun.com/xml/ns/j2ee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.bea.com/ns/weblogic/90
http://www.bea.com/ns/weblogic/90/weblogic-ejb-jar.xsd">
<weblogic-enterprise-bean>
<ejb-name>OrquestratorBean</ejb-name>
<jndi-name>OrquestratorBean</jndi-name>
<dispatch-policy>ResponseTimeReqClass-0</dispatch-policy>
</weblogic-enterprise-bean>
</weblogic-ejb-jar>
I've compiled this into a JAR and deployed it on WebLogic, as a library shared by administrative server and all cluster nodes on my solution (it's in "Active" state).
As I've seen in several tutorials and examples, I'm using this code on my application, in order to call the bean:
InitialContext ic = null;
try {
Hashtable<String,String> env = new Hashtable<String,String>();
env.put(Context.INITIAL_CONTEXT_FACTORY, "weblogic.jndi.WLInitialContextFactory");
env.put(Context.PROVIDER_URL, "t3://localhost:7001");
ic = new InitialContext(env);
}
catch(Exception e) {
System.out.println("\n\t Didn't get InitialContext: "+e);
}
//
try {
Object obj = ic.lookup("OrquestratorBean");
OrquestratorRemote remote =(OrquestratorRemote)obj;
System.out.println("\n\n\t++ Remote => "+ remote.getClass());
System.out.println("\n\n\t++ initOrquestrator()");
remote.initOrquestrator();
}
catch(Exception e) {
System.out.println("\n\n\t WorkManager Exception => "+ e);
e.printStackTrace();
}
Unfortunately, this don't work. It throws an exception on runtime, as follows:
WorkManager Exception =>
javax.naming.NameNotFoundException:
Unable to resolve 'OrquestratorBean'.
Resolved '' [Root exception is
javax.naming.NameNotFoundException:
Unable to resolve 'OrquestratorBean'.
Resolved '']; remaining name
'OrquestratorBean'
After seeing this, I've even tried changing this line
Object obj = ic.lookup("OrquestratorBean");
to this:
Object obj = ic.lookup("OrquestratorBean#orquestrator.OrquestratorBean");
but the result was the same runtime exception.
Can anyone please help me detecting what am I doing wrong here? I'm having a bad time debugging this, as I don't know how to check out what may be causing this issue...
Thanks in advance for your patience and help.
Your EJB gets bound under the following JNDI name (when deployed as EJB module):
Object obj = ic.lookup("OrquestratorBean#orquestrator.OrquestratorRemote");
Note that I deployed your code (without the weblogic-ejb-jar.xml) as an EJB module, not as a shared library.
seems like your mapped-name in ejb-jar.xml "Orquestrator" may be overriding the mappedName=OrquestratorBean setting of the Bean.
Have you tried ic.lookup for "Orquestrator" ?