2
我想讓下面的代碼工作,所以我可以從JPA實體中使用。Camel JPA - 沒有EntityManager的持久性提供者名爲camel
String DATASOURCE_CONTEXT = "java:jboss/datasources/WikiDS";
Connection result = null;
DataSource datasource = null;
try {
Context initialContext = new InitialContext();
datasource = (DataSource)initialContext.lookup(DATASOURCE_CONTEXT);
if (datasource == null) {
System.out.println("Data source is null");
}
else {
System.out.println("Data source is OK!!!");
}
}
catch(NamingException ex) {
System.out.println("Naming exception is: " + ex.getMessage());
}
SimpleRegistry reg = new SimpleRegistry() ;
reg.put("myDataSource",datasource);
CamelContext context = new DefaultCamelContext(reg);
ConnectionFactory connectionFactory = new ActiveMQConnectionFactory("vm://localhost?broker.persistent=false");
context.addComponent("test-jms", JmsComponent.jmsComponentAutoAcknowledge(connectionFactory));
context.addRoutes(new RouteBuilder() {
public void configure() {
from("jpa://org.apache.camel.example.jmstofile?consumer.namedQuery=step1&consumeDelete=false").to("file://test");
}
});
ProducerTemplate template = context.createProducerTemplate();
context.start();
無論我做什麼,我會得到以下例外。
[錯誤]無法執行目標org.codehaus.mojo:exec-maven-plugin:1.1.1:項目上的java(default-cli)camel-example-jms-file:執行Java時發生異常類。 null:InvocationTargetException:否EntityManager的持久性提供者名爲camel。
任何想法如何解決這一問題?
問候,
肖恩