Apache Camel http4 POST throwing java.lang.NoSuchMethodError - apache-camel

i'm trying to read file with xml and then post it to URL using HTTP4. But keep getting the following exception.
i'm using Apache Camel version 2.11.0, with JDK 1.7 on Linux
Here is code:
public static void main(String args[]) throws Exception {
// create CamelContext
CamelContext context = new DefaultCamelContext();
// add our route to the CamelContext
context.addRoutes(new RouteBuilder() {
public void configure() {
from("file:/home/projects/camelinaction-source/chapter1/file-copy/data/templates")
.convertBodyTo(String.class)
.setHeader(Exchange.HTTP_METHOD, constant(HttpMethods.POST))
.to("http4://testserver:8080/rest/test")
.setHeader(Exchange.FILE_NAME, constant("response.xml"))
.to("file:/home/projects/hyperlocal");
}
});
// start the route and let it do its work
context.start();
Thread.sleep(10000);
// stop the CamelContext
context.stop();
}
Here is the exception.
org.apache.camel.util.ObjectHelper.notNull(Ljava/lang/Object;Ljava/lang/String;)Ljava/lang/Object;
[INFO] ------------------------------------------------------------------------
[INFO] Trace
org.apache.maven.lifecycle.LifecycleExecutionException: An exception occured while executing the Java class. null
at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoals(DefaultLifecycleExecutor.java:719)
at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeStandaloneGoal(DefaultLifecycleExecutor.java:569)
at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoal(DefaultLifecycleExecutor.java:539)
at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoalAndHandleFailures(DefaultLifecycleExecutor.java:387)
at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeTaskSegments(DefaultLifecycleExecutor.java:348)
at org.apache.maven.lifecycle.DefaultLifecycleExecutor.execute(DefaultLifecycleExecutor.java:180)
at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:328)
at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:138)
at org.apache.maven.cli.MavenCli.main(MavenCli.java:362)
at org.apache.maven.cli.compat.CompatibleMain.main(CompatibleMain.java:60)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:601)
at org.codehaus.classworlds.Launcher.launchEnhanced(Launcher.java:315)
at org.codehaus.classworlds.Launcher.launch(Launcher.java:255)
at org.codehaus.classworlds.Launcher.mainWithExitCode(Launcher.java:430)
at org.codehaus.classworlds.Launcher.main(Launcher.java:375)
Caused by: org.apache.maven.plugin.MojoExecutionException: An exception occured while executing the Java class. null
at org.codehaus.mojo.exec.ExecJavaMojo.execute(ExecJavaMojo.java:338)
at org.apache.maven.plugin.DefaultPluginManager.executeMojo(DefaultPluginManager.java:490)
at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoals(DefaultLifecycleExecutor.java:694)
... 17 more
Caused by: java.lang.reflect.InvocationTargetException
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:601)
at org.codehaus.mojo.exec.ExecJavaMojo$1.run(ExecJavaMojo.java:283)
at java.lang.Thread.run(Thread.java:722)
Caused by: java.lang.NoSuchMethodError: org.apache.camel.util.ObjectHelper.notNull(Ljava/lang/Object;Ljava/lang/String;)Ljava/lang/Object;
at org.apache.camel.component.http.HttpEndpoint.createHttpClient(HttpEndpoint.java:104)
at org.apache.camel.component.http.HttpProducer.<init>(HttpProducer.java:72)
at org.apache.camel.component.http.HttpEndpoint.createProducer(HttpEndpoint.java:93)
at org.apache.camel.impl.ProducerCache.doGetProducer(ProducerCache.java:391)
at org.apache.camel.impl.ProducerCache.acquireProducer(ProducerCache.java:114)
at org.apache.camel.impl.ProducerCache.startProducer(ProducerCache.java:145)
at org.apache.camel.processor.SendProcessor.doStart(SendProcessor.java:175)
at org.apache.camel.support.ServiceSupport.start(ServiceSupport.java:60)
at org.apache.camel.util.ServiceHelper.startService(ServiceHelper.java:62)
at org.apache.camel.util.ServiceHelper.startService(ServiceHelper.java:52)
at org.apache.camel.util.ServiceHelper.startServices(ServiceHelper.java:73)
at org.apache.camel.processor.DelegateAsyncProcessor.doStart(DelegateAsyncProcessor.java:78)
at org.apache.camel.support.ServiceSupport.start(ServiceSupport.java:60)
at org.apache.camel.util.ServiceHelper.startService(ServiceHelper.java:62)
at org.apache.camel.util.ServiceHelper.startService(ServiceHelper.java:52)
at org.apache.camel.util.ServiceHelper.startServices(ServiceHelper.java:73)
at org.apache.camel.processor.DelegateAsyncProcessor.doStart(DelegateAsyncProcessor.java:78)
at org.apache.camel.processor.interceptor.TraceInterceptor.doStart(TraceInterceptor.java:358)
at org.apache.camel.support.ServiceSupport.start(ServiceSupport.java:60)
at org.apache.camel.util.ServiceHelper.startService(ServiceHelper.java:62)
at org.apache.camel.util.ServiceHelper.startService(ServiceHelper.java:52)
at org.apache.camel.util.ServiceHelper.startServices(ServiceHelper.java:73)
at org.apache.camel.processor.RedeliveryErrorHandler.doStart(RedeliveryErrorHandler.java:1064)
at org.apache.camel.support.ChildServiceSupport.start(ChildServiceSupport.java:41)
at org.apache.camel.support.ChildServiceSupport.start(ChildServiceSupport.java:28)
at org.apache.camel.util.ServiceHelper.startService(ServiceHelper.java:62)
at org.apache.camel.util.ServiceHelper.startService(ServiceHelper.java:52)
at org.apache.camel.util.ServiceHelper.startServices(ServiceHelper.java:73)
at org.apache.camel.processor.interceptor.DefaultChannel.doStart(DefaultChannel.java:153)
at org.apache.camel.support.ServiceSupport.start(ServiceSupport.java:60)
at org.apache.camel.util.ServiceHelper.startService(ServiceHelper.java:62)
at org.apache.camel.util.ServiceHelper.startService(ServiceHelper.java:52)
at org.apache.camel.util.ServiceHelper.startServices(ServiceHelper.java:85)
at org.apache.camel.processor.MulticastProcessor.doStart(MulticastProcessor.java:938)
at org.apache.camel.support.ServiceSupport.start(ServiceSupport.java:60)
at org.apache.camel.util.ServiceHelper.startService(ServiceHelper.java:62)
at org.apache.camel.util.ServiceHelper.startService(ServiceHelper.java:52)
at org.apache.camel.util.ServiceHelper.startServices(ServiceHelper.java:73)
at org.apache.camel.processor.DelegateAsyncProcessor.doStart(DelegateAsyncProcessor.java:78)
at org.apache.camel.support.ServiceSupport.start(ServiceSupport.java:60)
at org.apache.camel.util.ServiceHelper.startService(ServiceHelper.java:62)
at org.apache.camel.util.ServiceHelper.startService(ServiceHelper.java:52)
at org.apache.camel.util.ServiceHelper.startServices(ServiceHelper.java:73)
at org.apache.camel.processor.DelegateAsyncProcessor.doStart(DelegateAsyncProcessor.java:78)
at org.apache.camel.processor.UnitOfWorkProcessor.doStart(UnitOfWorkProcessor.java:88)
at org.apache.camel.support.ServiceSupport.start(ServiceSupport.java:60)
at org.apache.camel.util.ServiceHelper.startService(ServiceHelper.java:62)
at org.apache.camel.util.ServiceHelper.startService(ServiceHelper.java:52)
at org.apache.camel.util.ServiceHelper.startServices(ServiceHelper.java:73)
at org.apache.camel.processor.DelegateAsyncProcessor.doStart(DelegateAsyncProcessor.java:78)
at org.apache.camel.support.ServiceSupport.start(ServiceSupport.java:60)
at org.apache.camel.util.ServiceHelper.startService(ServiceHelper.java:62)
at org.apache.camel.util.ServiceHelper.startService(ServiceHelper.java:52)
at org.apache.camel.util.ServiceHelper.startServices(ServiceHelper.java:73)
at org.apache.camel.processor.DelegateAsyncProcessor.doStart(DelegateAsyncProcessor.java:78)
at org.apache.camel.support.ServiceSupport.start(ServiceSupport.java:60)
at org.apache.camel.util.ServiceHelper.startService(ServiceHelper.java:62)
at org.apache.camel.impl.RouteService.startChildService(RouteService.java:322)
at org.apache.camel.impl.RouteService.warmUp(RouteService.java:151)
at org.apache.camel.impl.DefaultCamelContext.doWarmUpRoutes(DefaultCamelContext.java:1986)
at org.apache.camel.impl.DefaultCamelContext.safelyStartRouteServices(DefaultCamelContext.java:1914)
at org.apache.camel.impl.DefaultCamelContext.doStartOrResumeRoutes(DefaultCamelContext.java:1702)
at org.apache.camel.impl.DefaultCamelContext.doStartCamel(DefaultCamelContext.java:1583)
at org.apache.camel.impl.DefaultCamelContext.doStart(DefaultCamelContext.java:1444)
at org.apache.camel.support.ServiceSupport.start(ServiceSupport.java:60)
at org.apache.camel.impl.DefaultCamelContext.start(DefaultCamelContext.java:1412)
at camelinaction.FileCopierWithCamel.main(FileCopierWithCamel.java:52)
... 6 more
Here is the maven dependency i have in pom.xml
<dependencies>
<dependency>
<groupId>org.apache.camel</groupId>
<artifactId>camel-core</artifactId>
</dependency>
<dependency>
<groupId>org.apache.camel</groupId>
<artifactId>camel-http4</artifactId>
<version>2.11.0</version>
</dependency>

It really does sound like you have mixed versions of Camel JARs on the classpath. Can you double check that all your Camel JARs is the same version?
Also you should have camel-http4 JAR on the classpath, and its dependencies.

Related

Unable To Perform Actions In Appium Because PageFactory Not Identified

I want to launch and perform actions like enter username details in application
but my execution is failing again and again because of error
My Code
public class VerifyProjectFromApp {
WebDriver driver;
AppLaunch toDoistAppLaunch;
HomePage homePage;
LoginPage login;
#BeforeMethod
public void startapplication() {
toDoistAppLaunch= new AppLaunch(driver);
this.driver=toDoistAppLaunch.launchApplication();
}
#Test
public void verifyCreatedProjectInApp() {
try{
//-Read create project value from properties file
Properties prop = new Properties();
InputStream input = null;
input = new FileInputStream(System.getProperty("user.dir") +
File.separator +"TodoistInputData.properties");
prop.load(input);
//-Read uuid from properties file
String email_id = prop.getProperty("email_id");
System.out.println("\t" + "email_id =" + email_id + "\r\n");
//-Read project name from properties file
String password = prop.getProperty("password");
System.out.println("\t" + "projectName =" + password + "\r\n");
login = new LoginPage(driver);
homePage = new HomePage(driver);
login.loginInApplication(email_id, password);
Utils.waitForPageLoadingToComplete(driver);
homePage.clickOnSideMenu();
Utils.pauseTestExecution(10);
} catch (Exception e) {
e.printStackTrace();
}
}
===================================================
public class LoginPage {
public static final String packageName = "com.todoist";
AndroidDriver<MobileElement> driver;
public LoginPage(WebDriver driver){
this.driver = (AndroidDriver<MobileElement>)driver;
PageFactory.initElements(new AppiumFieldDecorator(driver), this);
}
#AndroidFindBy(id=packageName+":id/btn_welcome_continue_with_email")
MobileElement continueButtonWithGmail;
#AndroidFindBy(id=packageName+":id/email_exists_input")
MobileElement enterEmailId;
#AndroidFindBy(id=packageName+":id/log_in_password")
MobileElement enterPassword;
#AndroidFindBy(id=packageName+":id/btn_continue_with_email")
MobileElement loginwithGmail;
#AndroidFindBy(id=packageName+":id/btn_log_in")
MobileElement loginButton;
public void clickOnContinueButtonWithGmail() {
continueButtonWithGmail.click();
}
public void enterEmailAddress(String emailId) {
enterEmailId.sendKeys(emailId);
}
public void enterPassword(String pass) {
enterPassword.sendKeys(pass);
}
public void clickOnGmailButton() {
loginwithGmail.click();
}
public void clickOnLoginButton() {
loginButton.click();
}
public void loginInApplication(String emailId,String password) {
try {
clickOnContinueButtonWithGmail();
Utils.waitForPageLoadingToComplete(driver);
enterEmailAddress(emailId);
Utils.waitForPageLoadingToComplete(driver);
clickOnGmailButton();
Utils.waitForPageLoadingToComplete(driver);
enterPassword(password);
Utils.waitForPageLoadingToComplete(driver);
clickOnLoginButton();
} catch(Exception e) {
e.printStackTrace();
}
}
=============================================================================================
Error Coming
[TestNG] Running:
C:\Users\Daffodil-255\AppData\Local\Temp\testng-eclipse--467741697\testng-customsuite.xml
Print app path E:\TodoistAutomation\Android_Todoist_Project\apkfile\Todoist_v12.8_apkpure.com.apk
Jul 25, 2018 11:57:52 AM io.appium.java_client.remote.AppiumCommandExecutor$1 lambda$0
INFO: Detected dialect: W3C
email_id =tarun.dabbs#daffodilsw.com
projectName =123456
Jul 25, 2018 11:57:52 AM org.openqa.selenium.remote.ErrorCodes toStatus
INFO: HTTP Status: '404' -> incorrect JSON status mapping for 'unknown method' (405 expected)
FAILED CONFIGURATION: #AfterMethod closeApplication
org.openqa.selenium.UnsupportedCommandException: Method has not yet been implemented
Build info: version: '3.13.0', revision: '2f0d292', time: '2018-06-25T15:32:14.902Z'
System info: host: 'DAFFODILLAP-265', ip: '172.18.1.128', os.name: 'Windows 8.1', os.arch: 'amd64', os.version: '6.3', java.version: '1.8.0_65'
Driver info: io.appium.java_client.android.AndroidDriver
Capabilities {app: E:\TodoistAutomation\Androi..., appActivity: com.todoist.activity.HomeAc..., appPackage: com.todoist, appium-version: 1.8.1, databaseEnabled: false, desired: {app: E:\TodoistAutomation\Androi..., appActivity: com.todoist.activity.HomeAc..., appPackage: com.todoist, appium-version: 1.8.1, deviceName: Nexus5X1, platformName: android, platformVersion: 7.1.1}, deviceManufacturer: Google, deviceModel: Android SDK built for x86, deviceName: emulator-5554, deviceScreenSize: 1080x1920, deviceUDID: emulator-5554, javascriptEnabled: true, locationContextEnabled: false, networkConnectionEnabled: true, platform: LINUX, platformName: Android, platformVersion: 7.1.1, takesScreenshot: true, warnings: {}, webStorageEnabled: false}
Session ID: 7333c28b-2ec8-48b2-89c0-b04e2c90ec74
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:422)
at org.openqa.selenium.remote.http.W3CHttpResponseCodec.createException(W3CHttpResponseCodec.java:187)
at org.openqa.selenium.remote.http.W3CHttpResponseCodec.decode(W3CHttpResponseCodec.java:122)
at org.openqa.selenium.remote.http.W3CHttpResponseCodec.decode(W3CHttpResponseCodec.java:49)
at org.openqa.selenium.remote.HttpCommandExecutor.execute(HttpCommandExecutor.java:158)
at io.appium.java_client.remote.AppiumCommandExecutor.execute(AppiumCommandExecutor.java:231)
at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:548)
at io.appium.java_client.DefaultGenericMobileDriver.execute(DefaultGenericMobileDriver.java:46)
at io.appium.java_client.AppiumDriver.execute(AppiumDriver.java:1)
at io.appium.java_client.android.AndroidDriver.execute(AndroidDriver.java:1)
at org.openqa.selenium.remote.RemoteWebDriver.close(RemoteWebDriver.java:438)
at com.todoist.tests.VerifyProjectFromApp.closeApplication(VerifyProjectFromApp.java:61)
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.testng.internal.MethodInvocationHelper.invokeMethod(MethodInvocationHelper.java:85)
at org.testng.internal.Invoker.invokeConfigurationMethod(Invoker.java:510)
at org.testng.internal.Invoker.invokeConfigurations(Invoker.java:211)
at org.testng.internal.Invoker.invokeMethod(Invoker.java:703)
at org.testng.internal.Invoker.invokeTestMethod(Invoker.java:816)
at org.testng.internal.Invoker.invokeTestMethods(Invoker.java:1124)
at org.testng.internal.TestMethodWorker.invokeTestMethods(TestMethodWorker.java:125)
at org.testng.internal.TestMethodWorker.run(TestMethodWorker.java:108)
at org.testng.TestRunner.privateRun(TestRunner.java:774)
at org.testng.TestRunner.run(TestRunner.java:624)
at org.testng.SuiteRunner.runTest(SuiteRunner.java:359)
at org.testng.SuiteRunner.runSequentially(SuiteRunner.java:354)
at org.testng.SuiteRunner.privateRun(SuiteRunner.java:312)
at org.testng.SuiteRunner.run(SuiteRunner.java:261)
at org.testng.SuiteRunnerWorker.runSuite(SuiteRunnerWorker.java:52)
at org.testng.SuiteRunnerWorker.run(SuiteRunnerWorker.java:86)
at org.testng.TestNG.runSuitesSequentially(TestNG.java:1215)
at org.testng.TestNG.runSuitesLocally(TestNG.java:1140)
at org.testng.TestNG.run(TestNG.java:1048)
at org.testng.remote.AbstractRemoteTestNG.run(AbstractRemoteTestNG.java:132)
at org.testng.remote.RemoteTestNG.initAndRun(RemoteTestNG.java:236)
at org.testng.remote.RemoteTestNG.main(RemoteTestNG.java:81)
FAILED: verifyCreatedProjectInApp
java.lang.NoClassDefFoundError: net/sf/cglib/proxy/MethodInterceptor
at com.todoist.pages.LoginPage.<init>(LoginPage.java:22)
at com.todoist.tests.VerifyProjectFromApp.verifyCreatedProjectInApp(VerifyProjectFromApp.java:46)
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.testng.internal.MethodInvocationHelper.invokeMethod(MethodInvocationHelper.java:85)
at org.testng.internal.Invoker.invokeMethod(Invoker.java:639)
at org.testng.internal.Invoker.invokeTestMethod(Invoker.java:816)
at org.testng.internal.Invoker.invokeTestMethods(Invoker.java:1124)
at org.testng.internal.TestMethodWorker.invokeTestMethods(TestMethodWorker.java:125)
at org.testng.internal.TestMethodWorker.run(TestMethodWorker.java:108)
at org.testng.TestRunner.privateRun(TestRunner.java:774)
at org.testng.TestRunner.run(TestRunner.java:624)
at org.testng.SuiteRunner.runTest(SuiteRunner.java:359)
at org.testng.SuiteRunner.runSequentially(SuiteRunner.java:354)
at org.testng.SuiteRunner.privateRun(SuiteRunner.java:312)
at org.testng.SuiteRunner.run(SuiteRunner.java:261)
at org.testng.SuiteRunnerWorker.runSuite(SuiteRunnerWorker.java:52)
at org.testng.SuiteRunnerWorker.run(SuiteRunnerWorker.java:86)
at org.testng.TestNG.runSuitesSequentially(TestNG.java:1215)
at org.testng.TestNG.runSuitesLocally(TestNG.java:1140)
at org.testng.TestNG.run(TestNG.java:1048)
at org.testng.remote.AbstractRemoteTestNG.run(AbstractRemoteTestNG.java:132)
at org.testng.remote.RemoteTestNG.initAndRun(RemoteTestNG.java:236)
at org.testng.remote.RemoteTestNG.main(RemoteTestNG.java:81)
Caused by: java.lang.ClassNotFoundException: net.sf.cglib.proxy.MethodInterceptor
at java.net.URLClassLoader.findClass(URLClassLoader.java:381)
at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:331)
at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
... 26 more
===============================================
Default test
Tests run: 1, Failures: 1, Skips: 0
Configuration Failures: 1, Skips: 0
===============================================
===============================================
Default suite
Total tests run: 1, Failures: 1, Skips: 0
Configuration Failures: 1, Skips: 0
===============================================
[TestNG] Time taken by org.testng.reporters.SuiteHTMLReporter#19bb089b: 171 ms
[TestNG] Time taken by org.testng.reporters.XMLReporter#35bbe5e8: 14 ms
[TestNG] Time taken by org.testng.reporters.JUnitReportReporter#6bdf28bb: 8 ms
[TestNG] Time taken by org.testng.reporters.jq.Main#1fbc7afb: 65 ms
[TestNG] Time taken by org.testng.reporters.EmailableReporter2#129a8472: 15 ms
[TestNG] Time taken by [FailedReporter passed=0 failed=0 skipped=0]: 11 ms
Issue happens due this:
ClassNotFoundException: net.sf.cglib.proxy.MethodInterceptor
to fix this you need to add cglib:cglib dependency:
<!-- https://mvnrepository.com/artifact/cglib/cglib -->
<dependency>
<groupId>cglib</groupId>
<artifactId>cglib</artifactId>
<version>3.2.7</version>
</dependency>
hope this helps,
Add both cglib and asm dependency in your project. This will solve your problem.
cglib-3.2.7.jar
asm-6.2.jar

PersistenceContext EntityManager (JPA)

I am creating a Java EE application using jpa.
The problem in #PersistenceContext(unitName = "airline") when i comment this line it give me error null_pointer_exception and when put it getting the following error when the code is run on server.
Info: visiting unvisited references
Info: visiting unvisited references
Info: visiting unvisited references
Info: visiting unvisited references
Info: visiting unvisited references
Info: visiting unvisited references
Info: visiting unvisited references
Info: visiting unvisited references
Info: visiting unvisited references
Info: visiting unvisited references
Info: visiting unvisited references
Info: visiting unvisited references
Info: visiting unvisited references
Info: visiting unvisited references
Info: visiting unvisited references
Info: visiting unvisited references
Info: visiting unvisited references
Info: visiting unvisited references
Info: visiting unvisited references
Info: visiting unvisited references
Severe: Exception while invoking class org.glassfish.persistence.jpa.JPADeployer prepare method
Severe: java.lang.RuntimeException: Could not resolve a persistence unit corresponding to the persistence-context-ref-name [com.airline.service.PassengerService/entityManager] in the scope of the module called [FlightPassengersJPA]. Please verify your application.
at com.sun.enterprise.deployment.BundleDescriptor.findReferencedPUViaEMRef(BundleDescriptor.java:731)
at com.sun.enterprise.deployment.BundleDescriptor.findReferencedPUsViaPCRefs(BundleDescriptor.java:719)
at org.glassfish.web.deployment.descriptor.WebBundleDescriptorImpl.findReferencedPUs(WebBundleDescriptorImpl.java:1037)
at org.glassfish.persistence.jpa.JPADeployer.createEMFs(JPADeployer.java:186)
at org.glassfish.persistence.jpa.JPADeployer.prepare(JPADeployer.java:168)
at com.sun.enterprise.v3.server.ApplicationLifecycle.prepareModule(ApplicationLifecycle.java:925)
at com.sun.enterprise.v3.server.ApplicationLifecycle.deploy(ApplicationLifecycle.java:434)
at com.sun.enterprise.v3.server.ApplicationLifecycle.deploy(ApplicationLifecycle.java:219)
at org.glassfish.deployment.admin.DeployCommand.execute(DeployCommand.java:491)
at com.sun.enterprise.v3.admin.CommandRunnerImpl$2$1.run(CommandRunnerImpl.java:539)
at com.sun.enterprise.v3.admin.CommandRunnerImpl$2$1.run(CommandRunnerImpl.java:535)
at java.security.AccessController.doPrivileged(Native Method)
at javax.security.auth.Subject.doAs(Subject.java:360)
at com.sun.enterprise.v3.admin.CommandRunnerImpl$2.execute(CommandRunnerImpl.java:534)
at com.sun.enterprise.v3.admin.CommandRunnerImpl$3.run(CommandRunnerImpl.java:565)
at com.sun.enterprise.v3.admin.CommandRunnerImpl$3.run(CommandRunnerImpl.java:557)
at java.security.AccessController.doPrivileged(Native Method)
at javax.security.auth.Subject.doAs(Subject.java:360)
at com.sun.enterprise.v3.admin.CommandRunnerImpl.doCommand(CommandRunnerImpl.java:556)
at com.sun.enterprise.v3.admin.CommandRunnerImpl.doCommand(CommandRunnerImpl.java:1464)
at com.sun.enterprise.v3.admin.CommandRunnerImpl.access$1300(CommandRunnerImpl.java:109)
at com.sun.enterprise.v3.admin.CommandRunnerImpl$ExecutionContext.execute(CommandRunnerImpl.java:1846)
at com.sun.enterprise.v3.admin.CommandRunnerImpl$ExecutionContext.execute(CommandRunnerImpl.java:1722)
at com.sun.enterprise.v3.admin.AdminAdapter.doCommand(AdminAdapter.java:534)
at com.sun.enterprise.v3.admin.AdminAdapter.onMissingResource(AdminAdapter.java:224)
at org.glassfish.grizzly.http.server.StaticHttpHandlerBase.service(StaticHttpHandlerBase.java:189)
at com.sun.enterprise.v3.services.impl.ContainerMapper$HttpHandlerCallable.call(ContainerMapper.java:459)
at com.sun.enterprise.v3.services.impl.ContainerMapper.service(ContainerMapper.java:167)
at org.glassfish.grizzly.http.server.HttpHandler.runService(HttpHandler.java:206)
at org.glassfish.grizzly.http.server.HttpHandler.doHandle(HttpHandler.java:180)
at org.glassfish.grizzly.http.server.HttpServerFilter.handleRead(HttpServerFilter.java:235)
at org.glassfish.grizzly.filterchain.ExecutorResolver$9.execute(ExecutorResolver.java:119)
at org.glassfish.grizzly.filterchain.DefaultFilterChain.executeFilter(DefaultFilterChain.java:283)
at org.glassfish.grizzly.filterchain.DefaultFilterChain.executeChainPart(DefaultFilterChain.java:200)
at org.glassfish.grizzly.filterchain.DefaultFilterChain.execute(DefaultFilterChain.java:132)
at org.glassfish.grizzly.filterchain.DefaultFilterChain.process(DefaultFilterChain.java:111)
at org.glassfish.grizzly.ProcessorExecutor.execute(ProcessorExecutor.java:77)
at org.glassfish.grizzly.nio.transport.TCPNIOTransport.fireIOEvent(TCPNIOTransport.java:536)
at org.glassfish.grizzly.strategies.AbstractIOStrategy.fireIOEvent(AbstractIOStrategy.java:112)
at org.glassfish.grizzly.strategies.WorkerThreadIOStrategy.run0(WorkerThreadIOStrategy.java:117)
at org.glassfish.grizzly.strategies.WorkerThreadIOStrategy.access$100(WorkerThreadIOStrategy.java:56)
at org.glassfish.grizzly.strategies.WorkerThreadIOStrategy$WorkerThreadRunnable.run(WorkerThreadIOStrategy.java:137)
at org.glassfish.grizzly.threadpool.AbstractThreadPool$Worker.doWork(AbstractThreadPool.java:591)
at org.glassfish.grizzly.threadpool.AbstractThreadPool$Worker.run(AbstractThreadPool.java:571)
at java.lang.Thread.run(Thread.java:748)
Severe: Exception while preparing the app
Severe: Exception during lifecycle processing
java.lang.RuntimeException: Could not resolve a persistence unit corresponding to the persistence-context-ref-name [com.airline.service.PassengerService/entityManager] in the scope of the module called [FlightPassengersJPA]. Please verify your application.
at com.sun.enterprise.deployment.BundleDescriptor.findReferencedPUViaEMRef(BundleDescriptor.java:731)
at com.sun.enterprise.deployment.BundleDescriptor.findReferencedPUsViaPCRefs(BundleDescriptor.java:719)
at org.glassfish.web.deployment.descriptor.WebBundleDescriptorImpl.findReferencedPUs(WebBundleDescriptorImpl.java:1037)
at org.glassfish.persistence.jpa.JPADeployer.createEMFs(JPADeployer.java:186)
at org.glassfish.persistence.jpa.JPADeployer.prepare(JPADeployer.java:168)
at com.sun.enterprise.v3.server.ApplicationLifecycle.prepareModule(ApplicationLifecycle.java:925)
at com.sun.enterprise.v3.server.ApplicationLifecycle.deploy(ApplicationLifecycle.java:434)
at com.sun.enterprise.v3.server.ApplicationLifecycle.deploy(ApplicationLifecycle.java:219)
at org.glassfish.deployment.admin.DeployCommand.execute(DeployCommand.java:491)
at com.sun.enterprise.v3.admin.CommandRunnerImpl$2$1.run(CommandRunnerImpl.java:539)
at com.sun.enterprise.v3.admin.CommandRunnerImpl$2$1.run(CommandRunnerImpl.java:535)
at java.security.AccessController.doPrivileged(Native Method)
at javax.security.auth.Subject.doAs(Subject.java:360)
at com.sun.enterprise.v3.admin.CommandRunnerImpl$2.execute(CommandRunnerImpl.java:534)
at com.sun.enterprise.v3.admin.CommandRunnerImpl$3.run(CommandRunnerImpl.java:565)
at com.sun.enterprise.v3.admin.CommandRunnerImpl$3.run(CommandRunnerImpl.java:557)
at java.security.AccessController.doPrivileged(Native Method)
at javax.security.auth.Subject.doAs(Subject.java:360)
at com.sun.enterprise.v3.admin.CommandRunnerImpl.doCommand(CommandRunnerImpl.java:556)
at com.sun.enterprise.v3.admin.CommandRunnerImpl.doCommand(CommandRunnerImpl.java:1464)
at com.sun.enterprise.v3.admin.CommandRunnerImpl.access$1300(CommandRunnerImpl.java:109)
at com.sun.enterprise.v3.admin.CommandRunnerImpl$ExecutionContext.execute(CommandRunnerImpl.java:1846)
at com.sun.enterprise.v3.admin.CommandRunnerImpl$ExecutionContext.execute(CommandRunnerImpl.java:1722)
at com.sun.enterprise.v3.admin.AdminAdapter.doCommand(AdminAdapter.java:534)
at com.sun.enterprise.v3.admin.AdminAdapter.onMissingResource(AdminAdapter.java:224)
at org.glassfish.grizzly.http.server.StaticHttpHandlerBase.service(StaticHttpHandlerBase.java:189)
at com.sun.enterprise.v3.services.impl.ContainerMapper$HttpHandlerCallable.call(ContainerMapper.java:459)
at com.sun.enterprise.v3.services.impl.ContainerMapper.service(ContainerMapper.java:167)
at org.glassfish.grizzly.http.server.HttpHandler.runService(HttpHandler.java:206)
at org.glassfish.grizzly.http.server.HttpHandler.doHandle(HttpHandler.java:180)
at org.glassfish.grizzly.http.server.HttpServerFilter.handleRead(HttpServerFilter.java:235)
at org.glassfish.grizzly.filterchain.ExecutorResolver$9.execute(ExecutorResolver.java:119)
at org.glassfish.grizzly.filterchain.DefaultFilterChain.executeFilter(DefaultFilterChain.java:283)
at org.glassfish.grizzly.filterchain.DefaultFilterChain.executeChainPart(DefaultFilterChain.java:200)
at org.glassfish.grizzly.filterchain.DefaultFilterChain.execute(DefaultFilterChain.java:132)
at org.glassfish.grizzly.filterchain.DefaultFilterChain.process(DefaultFilterChain.java:111)
at org.glassfish.grizzly.ProcessorExecutor.execute(ProcessorExecutor.java:77)
at org.glassfish.grizzly.nio.transport.TCPNIOTransport.fireIOEvent(TCPNIOTransport.java:536)
at org.glassfish.grizzly.strategies.AbstractIOStrategy.fireIOEvent(AbstractIOStrategy.java:112)
at org.glassfish.grizzly.strategies.WorkerThreadIOStrategy.run0(WorkerThreadIOStrategy.java:117)
at org.glassfish.grizzly.strategies.WorkerThreadIOStrategy.access$100(WorkerThreadIOStrategy.java:56)
at org.glassfish.grizzly.strategies.WorkerThreadIOStrategy$WorkerThreadRunnable.run(WorkerThreadIOStrategy.java:137)
at org.glassfish.grizzly.threadpool.AbstractThreadPool$Worker.doWork(AbstractThreadPool.java:591)
at org.glassfish.grizzly.threadpool.AbstractThreadPool$Worker.run(AbstractThreadPool.java:571)
at java.lang.Thread.run(Thread.java:748)
Severe: Exception while preparing the app : Could not resolve a persistence unit corresponding to the persistence-context-ref-name [com.airline.service.PassengerService/entityManager] in the scope of the module called [FlightPassengersJPA]. Please verify your application.
and my code :
AddPassenger.java
package com.airline.controllers;
import com.airline.models.FlightClass;
import com.airline.models.Gender;
import com.airline.models.Passenger;
import com.airline.service.PassengerService;
import java.io.IOException;
import java.io.PrintWriter;
import java.util.Calendar;
import java.util.Date;
import javax.ejb.EJB;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
#WebServlet(name = "AddPassenger", urlPatterns = {"/AddPassenger"})
public class AddPassenger extends HttpServlet {
#EJB
private PassengerService passengerService;
#Override
protected void doGet(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
processRequest(request, response);
Passenger passenger = new Passenger();
passenger.setFirstName("Loai");
passenger.setLastName("Amr");
Calendar cal = Calendar.getInstance();
cal.set(Calendar.YEAR, 1996);
cal.set(Calendar.MONTH, 9);
cal.set(Calendar.DAY_OF_MONTH, 30);
Date dob = cal.getTime();
passenger.setDob(dob);
passenger.setGender(Gender.Male);
passenger.setFlightClass(FlightClass.Couch);
passengerService.addPassenger(passenger);
System.out.println("First name : " + passenger.getFirstName());
}
#Override
protected void doPost(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
processRequest(request, response);
}
#Override
public String getServletInfo() {
return "Short description";
}// </editor-fold>
}
and class PassengerService :
package com.airline.service;
import com.airline.models.Passenger;
import javax.ejb.EJB;
import javax.ejb.LocalBean;
import javax.ejb.Stateless;
import javax.persistence.EntityManager;
import javax.persistence.PersistenceContext;
import javax.persistence.PersistenceContextType;
#Stateless
#LocalBean
public class PassengerService {
public PassengerService() {
}
#PersistenceContext(unitName = "airline")
private EntityManager entityManager;
public void addPassenger(Passenger passenger) {
entityManager.persist(passenger);
System.out.println("Done");
}
}
and persistence.xml
<?xml version="1.0" encoding="UTF-8"?>
<persistence version="2.1" xmlns="http://xmlns.jcp.org/xml/ns/persistence" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/persistence http://xmlns.jcp.org/xml/ns/persistence/persistence_2_1.xsd">
<persistence-unit name="FlightPassengersJPAPU" transaction-type="JTA">
<provider>org.hibernate.ejb.HibernatePersistence</provider>
<jta-data-source>jdbc/airline</jta-data-source>
<exclude-unlisted-classes>false</exclude-unlisted-classes>
<properties>
<property name="javax.persistence.schema-generation.database.action" value="create"/>
</properties>
</persistence-unit>
</persistence>
You need to define your persistence-unit in a file named persistence.xml. This should reside as resource in META-INF.
An example for that you can see in:
persistence.xml... The datasources you see there is defined in the configuration of the wildfly as you can see it in standalone.xml
In a similar way I think you have do define the datasource in glassfish.

Hibernate Maven Project Find Entity by id

I'm getting a null pointer exception. I'm not sure how to handle the generic classes:
Servlet.service() for servlet [LogServlet] in context with path [/CompanyProject] threw exceptionjava.lang.NullPointerException
at org.hibernate.internal.SessionImpl$IdentifierLoadAccessImpl.<init>(SessionImpl.java:2544)
at org.hibernate.internal.SessionImpl$IdentifierLoadAccessImpl.<init>(SessionImpl.java:2531)
at org.hibernate.internal.SessionImpl.byId(SessionImpl.java:1079)
at org.hibernate.internal.SessionImpl.get(SessionImpl.java:991)
at com.myproject.dao.MainDao.findById(MainDao.java:26)
at com.myproject.controller.LoginFilter.doFilter(LoginFilter.java:52)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:243)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:51)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:243)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:222)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:123)
at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:502)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:171)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:100)
at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:953)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:118)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:408)
at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1041)
at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:603)
at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:312)
at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)
Here is the code for the main dao
constructor:
public MainDao() {
session=(new Configuration().configure()).buildSessionFactory().openSession();
}
And the method:
public T findById(String i){
session.beginTransaction();
T obj= (T) session.get(managedClass,(Serializable) i);
session.getTransaction().commit();
return obj;
}
Ideas?
I just had to build path again to include hibernate jars for some reason.

Trouble in calling webservice from Apache camel

I am trying to call a web service from Apache Camel using CXF, that tries to convert the currency from one currency to other, but I am unable to call it because of endpoint resolution.
If any simple tutorials are there how to call webservices from Apache Camel please post..
Thanks in advance..
CamelContext is as below..
<?xml version="1.0" encoding="UTF-8" standalone="no"?><beans xmlns="http://www.springframework.org/schema/beans"
xmlns:cxf="http://camel.apache.org/schema/cxf"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
http://camel.apache.org/schema/spring
http://camel.apache.org/schema/spring/camel-spring.xsd">
<camelContext trace="false" xmlns="http://camel.apache.org/schema/spring">
<route>
<from uri="file:src/data/order?noop=true"/>
<log message=">>> ${body}" loggingLevel="INFO"/>
<to uri="cxf://http://www.webservicex.net/CurrencyConvertor.asmx?wsdlURL=http://www.webservicex.net/CurrencyConvertor.asmx?wsdl&serviceName={http://www.webserviceX.NET/}CurrencyConvertor&portName={http://www.webserviceX.NET/}CurrencyConvertorSoap&dataFormat=MESSAGE"/>
<log message=">>> ${body}" loggingLevel="INFO"/>
</route>
</camelContext>
</beans>
My order.xml is...
<?xml version="1.0" encoding="utf-8"?>
<soap12:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap12="http://www.w3.org/2003/05/soap-envelope">
<soap12:Body>
<web:ConversionRate>
<web:FromCurrency>AUD</web:FromCurrency>
<web:ToCurrency>USD</web:ToCurrency>
</web:ConversionRate>
</soap12:Body>
</soap12:Envelope>
This is the error i am facing while running the camel context ....
*************************************
Error occurred while running main from: org.apache.camel.spring.Main
java.lang.reflect.InvocationTargetException
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:606)
at org.apache.camel.maven.RunMojo$1.run(RunMojo.java:440)
at java.lang.Thread.run(Thread.java:744)
Caused by: org.apache.camel.FailedToCreateProducerException: Failed to create Producer for endpoint: Endpoint[cxf://http://www.webservicex.net/CurrencyConvertor.asmx?dataFormat=MESSAGE&portName=%7Bhttp%3A%2F%2Fwww.webserviceX.NET%2F%7DCurrencyConvertorSoap&serviceName=%7Bhttp%3A%2F%2Fwww.webserviceX.NET%2F%7DCurrencyConvertor&wsdlURL=http%3A%2F%2Fwww.webservicex.net%2FCurrencyConvertor.asmx%3Fwsdl]. Reason: org.apache.cxf.service.factory.ServiceConstructionException: Failed to create service.
at org.apache.camel.impl.ProducerCache.doGetProducer(ProducerCache.java:395)
at org.apache.camel.impl.ProducerCache.acquireProducer(ProducerCache.java:114)
at org.apache.camel.impl.ProducerCache.startProducer(ProducerCache.java:145)
at org.apache.camel.processor.SendProcessor.doStart(SendProcessor.java:175)
at org.apache.camel.support.ServiceSupport.start(ServiceSupport.java:60)
at org.apache.camel.util.ServiceHelper.startService(ServiceHelper.java:62)
at org.apache.camel.util.ServiceHelper.startService(ServiceHelper.java:52)
at org.apache.camel.util.ServiceHelper.startServices(ServiceHelper.java:73)
at org.apache.camel.processor.DelegateAsyncProcessor.doStart(DelegateAsyncProcessor.java:78)
at org.apache.camel.support.ServiceSupport.start(ServiceSupport.java:60)
at org.apache.camel.util.ServiceHelper.startService(ServiceHelper.java:62)
at org.apache.camel.util.ServiceHelper.startService(ServiceHelper.java:52)
at org.apache.camel.util.ServiceHelper.startServices(ServiceHelper.java:73)
at org.apache.camel.processor.DelegateAsyncProcessor.doStart(DelegateAsyncProcessor.java:78)
at org.apache.camel.processor.interceptor.TraceInterceptor.doStart(TraceInterceptor.java:358)
at org.apache.camel.support.ServiceSupport.start(ServiceSupport.java:60)
at org.apache.camel.util.ServiceHelper.startService(ServiceHelper.java:62)
at org.apache.camel.util.ServiceHelper.startService(ServiceHelper.java:52)
at org.apache.camel.processor.WrapProcessor.doStart(WrapProcessor.java:52)
at org.apache.camel.support.ServiceSupport.start(ServiceSupport.java:60)
at org.apache.camel.util.ServiceHelper.startService(ServiceHelper.java:62)
at org.apache.camel.util.ServiceHelper.startService(ServiceHelper.java:52)
at org.apache.camel.util.ServiceHelper.startServices(ServiceHelper.java:73)
at org.apache.camel.processor.RedeliveryErrorHandler.doStart(RedeliveryErrorHandler.java:1064)
at org.apache.camel.support.ChildServiceSupport.start(ChildServiceSupport.java:41)
at org.apache.camel.support.ChildServiceSupport.start(ChildServiceSupport.java:28)
at org.apache.camel.util.ServiceHelper.startService(ServiceHelper.java:62)
at org.apache.camel.util.ServiceHelper.startService(ServiceHelper.java:52)
at org.apache.camel.util.ServiceHelper.startServices(ServiceHelper.java:73)
at org.apache.camel.processor.interceptor.DefaultChannel.doStart(DefaultChannel.java:153)
at org.apache.camel.support.ServiceSupport.start(ServiceSupport.java:60)
at org.apache.camel.util.ServiceHelper.startService(ServiceHelper.java:62)
at org.apache.camel.util.ServiceHelper.startService(ServiceHelper.java:52)
at org.apache.camel.util.ServiceHelper.startServices(ServiceHelper.java:85)
at org.apache.camel.processor.MulticastProcessor.doStart(MulticastProcessor.java:938)
at org.apache.camel.support.ServiceSupport.start(ServiceSupport.java:60)
at org.apache.camel.util.ServiceHelper.startService(ServiceHelper.java:62)
at org.apache.camel.util.ServiceHelper.startService(ServiceHelper.java:52)
at org.apache.camel.util.ServiceHelper.startServices(ServiceHelper.java:73)
at org.apache.camel.processor.DelegateAsyncProcessor.doStart(DelegateAsyncProcessor.java:78)
at org.apache.camel.support.ServiceSupport.start(ServiceSupport.java:60)
at org.apache.camel.util.ServiceHelper.startService(ServiceHelper.java:62)
at org.apache.camel.util.ServiceHelper.startService(ServiceHelper.java:52)
at org.apache.camel.util.ServiceHelper.startServices(ServiceHelper.java:73)
at org.apache.camel.processor.DelegateAsyncProcessor.doStart(DelegateAsyncProcessor.java:78)
at org.apache.camel.processor.UnitOfWorkProcessor.doStart(UnitOfWorkProcessor.java:88)
at org.apache.camel.support.ServiceSupport.start(ServiceSupport.java:60)
at org.apache.camel.util.ServiceHelper.startService(ServiceHelper.java:62)
at org.apache.camel.util.ServiceHelper.startService(ServiceHelper.java:52)
at org.apache.camel.util.ServiceHelper.startServices(ServiceHelper.java:73)
at org.apache.camel.processor.DelegateAsyncProcessor.doStart(DelegateAsyncProcessor.java:78)
at org.apache.camel.support.ServiceSupport.start(ServiceSupport.java:60)
at org.apache.camel.util.ServiceHelper.startService(ServiceHelper.java:62)
at org.apache.camel.util.ServiceHelper.startService(ServiceHelper.java:52)
at org.apache.camel.util.ServiceHelper.startServices(ServiceHelper.java:73)
at org.apache.camel.processor.DelegateAsyncProcessor.doStart(DelegateAsyncProcessor.java:78)
at org.apache.camel.support.ServiceSupport.start(ServiceSupport.java:60)
at org.apache.camel.util.ServiceHelper.startService(ServiceHelper.java:62)
at org.apache.camel.impl.RouteService.startChildService(RouteService.java:322)
at org.apache.camel.impl.RouteService.warmUp(RouteService.java:151)
at org.apache.camel.impl.DefaultCamelContext.doWarmUpRoutes(DefaultCamelContext.java:2000)
at org.apache.camel.impl.DefaultCamelContext.safelyStartRouteServices(DefaultCamelContext.java:1928)
at org.apache.camel.impl.DefaultCamelContext.doStartOrResumeRoutes(DefaultCamelContext.java:1716)
at org.apache.camel.impl.DefaultCamelContext.doStartCamel(DefaultCamelContext.java:1597)
at org.apache.camel.impl.DefaultCamelContext.doStart(DefaultCamelContext.java:1453)
at org.apache.camel.spring.SpringCamelContext.doStart(SpringCamelContext.java:179)
at org.apache.camel.support.ServiceSupport.start(ServiceSupport.java:60)
at org.apache.camel.impl.DefaultCamelContext.start(DefaultCamelContext.java:1421)
at org.apache.camel.spring.SpringCamelContext.maybeStart(SpringCamelContext.java:228)
at org.apache.camel.spring.SpringCamelContext.onApplicationEvent(SpringCamelContext.java:118)
at org.apache.camel.spring.CamelContextFactoryBean.onApplicationEvent(CamelContextFactoryBean.java:283)
at org.springframework.context.event.SimpleApplicationEventMulticaster.multicastEvent(SimpleApplicationEventMulticaster.java:97)
at org.springframework.context.support.AbstractApplicationContext.publishEvent(AbstractApplicationContext.java:327)
at org.springframework.context.support.AbstractApplicationContext.finishRefresh(AbstractApplicationContext.java:941)
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:475)
at org.springframework.context.support.ClassPathXmlApplicationContext.<init>(ClassPathXmlApplicationContext.java:139)
at org.springframework.context.support.ClassPathXmlApplicationContext.<init>(ClassPathXmlApplicationContext.java:93)
at org.apache.camel.spring.Main.createDefaultApplicationContext(Main.java:186)
at org.apache.camel.spring.Main.doStart(Main.java:140)
at org.apache.camel.support.ServiceSupport.start(ServiceSupport.java:60)
at org.apache.camel.main.MainSupport.run(MainSupport.java:141)
at org.apache.camel.main.MainSupport.run(MainSupport.java:332)
at org.apache.camel.spring.Main.main(Main.java:73)
... 6 more
Caused by: org.apache.cxf.service.factory.ServiceConstructionException: Failed to create service.
at org.apache.cxf.wsdl11.WSDLServiceFactory.<init>(WSDLServiceFactory.java:94)
at org.apache.cxf.service.factory.ReflectionServiceFactoryBean.buildServiceFromWSDL(ReflectionServiceFactoryBean.java:398)
at org.apache.cxf.service.factory.ReflectionServiceFactoryBean.initializeServiceModel(ReflectionServiceFactoryBean.java:534)
at org.apache.cxf.service.factory.ReflectionServiceFactoryBean.create(ReflectionServiceFactoryBean.java:248)
at org.apache.cxf.frontend.AbstractWSDLBasedEndpointFactory.createEndpoint(AbstractWSDLBasedEndpointFactory.java:101)
at org.apache.cxf.frontend.ClientFactoryBean.create(ClientFactoryBean.java:90)
at org.apache.camel.component.cxf.CxfEndpoint.createClient(CxfEndpoint.java:527)
at org.apache.camel.component.cxf.CxfProducer.doStart(CxfProducer.java:76)
at org.apache.camel.support.ServiceSupport.start(ServiceSupport.java:60)
at org.apache.camel.util.ServiceHelper.startService(ServiceHelper.java:62)
at org.apache.camel.impl.ProducerCache.doGetProducer(ProducerCache.java:393)
... 88 more
Caused by: javax.wsdl.WSDLException: WSDLException: faultCode=PARSER_ERROR: Problem parsing 'http://www.webservicex.net/CurrencyConvertor.asmx?wsdl'.: java.net.UnknownHostException: www.webservicex.net
at com.ibm.wsdl.xml.WSDLReaderImpl.getDocument(Unknown Source)
at com.ibm.wsdl.xml.WSDLReaderImpl.readWSDL(Unknown Source)
at com.ibm.wsdl.xml.WSDLReaderImpl.readWSDL(Unknown Source)
at org.apache.cxf.wsdl11.WSDLManagerImpl.loadDefinition(WSDLManagerImpl.java:249)
at org.apache.cxf.wsdl11.WSDLManagerImpl.getDefinition(WSDLManagerImpl.java:192)
at org.apache.cxf.wsdl11.WSDLServiceFactory.<init>(WSDLServiceFactory.java:92)
... 98 more
Caused by: java.net.UnknownHostException: www.webservicex.net
at java.net.AbstractPlainSocketImpl.connect(AbstractPlainSocketImpl.java:178)
at java.net.PlainSocketImpl.connect(PlainSocketImpl.java:172)
at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:392)
at java.net.Socket.connect(Socket.java:579)
at java.net.Socket.connect(Socket.java:528)
at sun.net.NetworkClient.doConnect(NetworkClient.java:180)
at sun.net.www.http.HttpClient.openServer(HttpClient.java:432)
at sun.net.www.http.HttpClient.openServer(HttpClient.java:527)
at sun.net.www.http.HttpClient.<init>(HttpClient.java:211)
at sun.net.www.http.HttpClient.New(HttpClient.java:308)
at sun.net.www.http.HttpClient.New(HttpClient.java:326)
at sun.net.www.protocol.http.HttpURLConnection.getNewHttpClient(HttpURLConnection.java:996)
at sun.net.www.protocol.http.HttpURLConnection.plainConnect(HttpURLConnection.java:932)
at sun.net.www.protocol.http.HttpURLConnection.connect(HttpURLConnection.java:850)
at sun.net.www.protocol.http.HttpURLConnection.getInputStream(HttpURLConnection.java:1300)
at com.sun.org.apache.xerces.internal.impl.XMLEntityManager.setupCurrentEntity(XMLEntityManager.java:637)
at com.sun.org.apache.xerces.internal.impl.XMLVersionDetector.determineDocVersion(XMLVersionDetector.java:189)
at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(XML11Configuration.java:812)
at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(XML11Configuration.java:777)
at com.sun.org.apache.xerces.internal.parsers.XMLParser.parse(XMLParser.java:141)
at com.sun.org.apache.xerces.internal.parsers.DOMParser.parse(DOMParser.java:243)
at enter code herecom.sun.org.apache.xerces.internal.jaxp.DocumentBuilderImpl.parse(DocumentBuilderImpl.java:347)
When accessing http://www.webservicex.net/CurrencyConvertor.asmx?wsdl your log says:
java.net.UnknownHostException
Check, if you have access to the internet. Or if you are behind a proxy server, you may first set the appropriate proxy settings. Find more information about that here.
That said, your SOAP request misses the web namespace. Without the appropriate setting, the server will complain.
xmlns:web="http://www.webserviceX.NET/"
I started the tests with:
final org.apache.camel.spring.Main main = new org.apache.camel.spring.Main();
main.setApplicationContextUri("META-INF/spring/cxf-example.orig.xml");
main.start();

Indexing error in solr:Bad Request

I am using solr in my spring mvc project:
Here is the related code:
My configuration:
<bean id="solrServer" class="org.apache.solr.client.solrj.impl.CommonsHttpSolrServer">
<constructor-arg value="http://localhost:8180/sorl"/>
<property name="connectionTimeout" value="1000"/>
<property name="defaultMaxConnectionsPerHost" value="32"/>
<property name="maxTotalConnections" value="128"/>
</bean>
My domain:
...
#Entity
#Indexed
#Table(name="MySubject")
#Inheritance(strategy = InheritanceType.TABLE_PER_CLASS)
public class MySubject extends BaseObject
{
private static final long serialVersionUID = 1L;
#Column
#Field(index=Index.YES, analyze=Analyze.YES, store=Store.NO)
#org.apache.solr.client.solrj.beans.Field("type")
private String type;
.....
Indexing code:
try {
solrServer.addBean(subject);
solrServer.commit();
} catch (IOException | SolrServerException e) {
e.printStackTrace();
}
And I got exception:
Bad Request
request: http://localhost:8180/sorl/update?wt=javabin&version=2
at org.apache.solr.client.solrj.impl.CommonsHttpSolrServer.request(CommonsHttpSolrServer.java:427)
at org.apache.solr.client.solrj.impl.CommonsHttpSolrServer.request(CommonsHttpSolrServer.java:249)
at org.apache.solr.client.solrj.request.AbstractUpdateRequest.process(AbstractUpdateRequest.java:105)
at org.apache.solr.client.solrj.SolrServer.add(SolrServer.java:121)
at org.apache.solr.client.solrj.SolrServer.addBean(SolrServer.java:143)
at org.apache.solr.client.solrj.SolrServer.addBean(SolrServer.java:131)
In solr server, the log is :
org.apache.solr.common.SolrException log
SEVERE: org.apache.solr.common.SolrException: ERROR: [doc=null] unknown field 'type'
at org.apache.solr.update.DocumentBuilder.toDocument(DocumentBuilder.java:340)
at org.apache.solr.update.processor.RunUpdateProcessor.processAdd(RunUpdateProcessorFactory.java:60)
at org.apache.solr.update.processor.LogUpdateProcessor.processAdd(LogUpdateProcessorFactory.java:115)
at org.apache.solr.handler.XMLLoader.processUpdate(XMLLoader.java:157)
at org.apache.solr.handler.XMLLoader.load(XMLLoader.java:79)
at org.apache.solr.handler.ContentStreamHandlerBase.handleRequestBody(ContentStreamHandlerBase.java:58)
at org.apache.solr.handler.RequestHandlerBase.handleRequest(RequestHandlerBase.java:129)
at org.apache.solr.core.SolrCore.execute(SolrCore.java:1376)
at org.apache.solr.servlet.SolrDispatchFilter.execute(SolrDispatchFilter.java:365)
at org.apache.solr.servlet.SolrDispatchFilter.doFilter(SolrDispatchFilter.java:260)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:243)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:224)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:169)
at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:472)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:168)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:98)
at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:928)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:118)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:407)
at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:987)
at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:539)
at org.apache.tomcat.util.net.AprEndpoint$SocketProcessor.run(AprEndpoint.java:1815)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1110)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:603)
at java.lang.Thread.run(Thread.java:722)
Please kindly help me out.

Resources