Jodconverter exception: failed to start and connect in windows [duplicate] - java

This question already has an answer here:
OpenOffice convert doc to pdf with JAVA
(1 answer)
Closed 6 years ago.
Why I get the following exception..
I stuck with this issue with several days..
Please help me..
INFO: ProcessManager implementation is WindowsProcessManager
org.artofsolving.jodconverter.office.OfficeException: failed to start and connect
at org.artofsolving.jodconverter.office.ManagedOfficeProcess.startAndWait(ManagedOfficeProcess.java:61)
at org.artofsolving.jodconverter.office.PooledOfficeManager.start(PooledOfficeManager.java:102)
at org.artofsolving.jodconverter.office.ProcessPoolOfficeManager.start(ProcessPoolOfficeManager.java:59)
at com.hiringsteps.ats.util.service.impl.UtilService.convertWord2Pdf(UtilService.java:132)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:318)
at org.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint(ReflectiveMethodInvocation.java:183)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:150)
at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:110)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172)
at org.springframework.aop.interceptor.ExposeInvocationInterceptor.invoke(ExposeInvocationInterceptor.java:90)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172)
at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:202)
at $Proxy51.convertWord2Pdf(Unknown Source)
at com.hiringsteps.ats.applicant.facade.impl.ApplicantFacade.convert2PdfNHighlight(ApplicantFacade.java:553)
at com.hiringsteps.ats.applicant.facade.impl.ApplicantFacade.register(ApplicantFacade.java:433)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:318)
at org.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint(ReflectiveMethodInvocation.java:183)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:150)
at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:110)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172)
at org.springframework.aop.interceptor.ExposeInvocationInterceptor.invoke(ExposeInvocationInterceptor.java:90)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172)
at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:202)
at $Proxy65.register(Unknown Source)
at com.hiringsteps.ats.applicant.dwr.impl.ApplicantDwr.register(ApplicantDwr.java:107)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at org.directwebremoting.impl.ExecuteAjaxFilter.doFilter(ExecuteAjaxFilter.java:34)
at org.directwebremoting.impl.DefaultRemoter$1.doFilter(DefaultRemoter.java:472)
at org.directwebremoting.impl.DefaultRemoter.execute(DefaultRemoter.java:475)
at org.directwebremoting.impl.DefaultRemoter.execute(DefaultRemoter.java:323)
at org.directwebremoting.servlet.PlainCallHandler.handle(PlainCallHandler.java:52)
at org.directwebremoting.servlet.UrlProcessor.handle(UrlProcessor.java:101)
at org.directwebremoting.spring.DwrController.handleRequestInternal(DwrController.java:256)
at org.springframework.web.servlet.mvc.AbstractController.handleRequest(AbstractController.java:153)
at org.springframework.web.servlet.mvc.SimpleControllerHandlerAdapter.handle(SimpleControllerHandlerAdapter.java:48)
at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:923)
at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:852)
at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:882)
at org.springframework.web.servlet.FrameworkServlet.doPost(FrameworkServlet.java:789)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:727)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:820)
at org.mortbay.jetty.servlet.ServletHolder.handle(ServletHolder.java:487)
at org.mortbay.jetty.servlet.ServletHandler.handle(ServletHandler.java:362)
at org.mortbay.jetty.security.SecurityHandler.handle(SecurityHandler.java:216)
at org.mortbay.jetty.servlet.SessionHandler.handle(SessionHandler.java:181)
at org.mortbay.jetty.handler.ContextHandler.handle(ContextHandler.java:726)
at org.mortbay.jetty.webapp.WebAppContext.handle(WebAppContext.java:405)
at org.mortbay.jetty.handler.ContextHandlerCollection.handle(ContextHandlerCollection.java:206)
at org.mortbay.jetty.handler.HandlerCollection.handle(HandlerCollection.java:114)
at org.mortbay.jetty.handler.HandlerWrapper.handle(HandlerWrapper.java:152)
at org.mortbay.jetty.Server.handle(Server.java:324)
at org.mortbay.jetty.HttpConnection.handleRequest(HttpConnection.java:505)
at org.mortbay.jetty.HttpConnection$RequestHandler.content(HttpConnection.java:842)
at org.mortbay.jetty.HttpParser.parseNext(HttpParser.java:648)
at org.mortbay.jetty.HttpParser.parseAvailable(HttpParser.java:211)
at org.mortbay.jetty.HttpConnection.handle(HttpConnection.java:380)
at org.mortbay.io.nio.SelectChannelEndPoint.run(SelectChannelEndPoint.java:395)
at org.mortbay.thread.BoundedThreadPool$PoolThread.run(BoundedThreadPool.java:450)
Caused by: java.util.concurrent.ExecutionException: org.artofsolving.jodconverter.office.OfficeException: could not establish connection
at java.util.concurrent.FutureTask$Sync.innerGet(FutureTask.java:222)
at java.util.concurrent.FutureTask.get(FutureTask.java:83)
at org.artofsolving.jodconverter.office.ManagedOfficeProcess.startAndWait(ManagedOfficeProcess.java:59)
... 68 more
MY code is
public void convertWord2Pdf(String inputPath, String outputPath ) {
try {
File inputFile = new File(inputPath);
File outputFile = new File(outputPath);
OfficeManager officeManager = new DefaultOfficeManagerConfiguration().buildOfficeManager();
officeManager.start(); // may tweak the start and stop code to appear elsewhere for additional efficiency
DocumentFormat docFormat = new DocumentFormat("Portable Document Format", "pdf", "application/pdf");
Map map = new HashMap();
map.put("FilterName", "writer_pdf_Export");
PropertyValue[] aFilterData = new PropertyValue[1];
aFilterData[0] = new PropertyValue();
aFilterData[0].Name = "SelectPdfVersion";
aFilterData[0].Value = 1;
map.put("FilterData", aFilterData);
docFormat.setStoreProperties(DocumentFamily.TEXT, map);
OfficeDocumentConverter docConverter = new OfficeDocumentConverter(officeManager);
docConverter.convert(inputFile, outputFile, docFormat);
officeManager.stop();
} catch (Throwable e) {
e.printStackTrace();
}
}
And in my pom.xml
<dependency>
<groupId>org.artofsolving.jodconverter</groupId>
<artifactId>jodconverter-core</artifactId>
<version>3.0-beta-3</version>
</dependency>
Earlier my code was
public void convertWord2Pdf(String inputPath, String outputPath ) {
try {
File inputFile = new File(inputPath);
File outputFile = new File(outputPath);
OpenOfficeConnection connection = new SocketOpenOfficeConnection(8100);
connection.connect();
DocumentConverter converter = new OpenOfficeDocumentConverter(connection);
converter.convert(inputFile, outputFile);
//close the connection
connection.disconnect();
}
catch (Throwable e) {
e.printStackTrace();
}
}
And in pom.xml
<dependency>
<groupId>com.artofsolving</groupId>
<artifactId>jodconverter</artifactId>
<version>2.2.2</version>
</dependency>

Your code looks ok, but it seems that the open office service is not running, so the JODConverter cannot connect to it, thus the exception (org.artofsolving.jodconverter.office.OfficeException: failed to start and connect).
If it is running, probably the port is wrong.
You can take a look at your ports in use and try to figure out whether it is really operational or not.
From this source: http://www.artofsolving.com/node/10
JODConverter needs to connect to a running OpenOffice.org instance in order to perform the document conversions.
This is different from starting the OpenOffice.org program as you would normally do. OpenOffice.org can be configured to run as a service and listen for commands on a TCP port; there are a few ways to accomplish this but the simplest one is to start it from the command line with the following options:
You can start the service with:
soffice -headless -accept="socket,host=127.0.0.1,port=8100;urp;" -nofirststartwizard
For help under windows look at:
http://www.artofsolving.com/node/11
http://community.nuxeo.com/5.3/books/nuxeo-book/html/admin-openoffice.html

Related

How do I invoke a DiagnosticCommandMBean programmatically?

I would like to run an operation of the DiagnosticCommandMBean programatically.
As an example, I am trying with vmFlags(), which takes no arguments. Here is my test code:
ObjectName name = new ObjectName("com.sun.management:type=DiagnosticCommand");
String port = System.getProperty("com.sun.management.jmxremote.port");
JMXServiceURL url =
new JMXServiceURL("service:jmx:rmi:///jndi/rmi://:"+port+"/jmxrmi");
JMXConnector jmxc = JMXConnectorFactory.connect(url, null);
MBeanServerConnection mbsc = jmxc.getMBeanServerConnection();
MBeanInfo info = ManagementFactory.getPlatformMBeanServer().getMBeanInfo(name);
mbsc.invoke(
name,
info.getOperations()[13].getName(), // vmFlags
null,
null
);
Which gives me this exception:
javax.management.ReflectionException
at sun.management.DiagnosticCommandImpl.invoke(DiagnosticCommandImpl.java:233)
at com.sun.jmx.interceptor.DefaultMBeanServerInterceptor.invoke(DefaultMBeanServerInterceptor.java:819)
at com.sun.jmx.mbeanserver.JmxMBeanServer.invoke(JmxMBeanServer.java:801)
at javax.management.remote.rmi.RMIConnectionImpl.doOperation(RMIConnectionImpl.java:1466)
at javax.management.remote.rmi.RMIConnectionImpl.access$300(RMIConnectionImpl.java:76)
at javax.management.remote.rmi.RMIConnectionImpl$PrivilegedOperation.run(RMIConnectionImpl.java:1307)
at javax.management.remote.rmi.RMIConnectionImpl.doPrivilegedOperation(RMIConnectionImpl.java:1399)
at javax.management.remote.rmi.RMIConnectionImpl.invoke(RMIConnectionImpl.java:828)
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:483)
at sun.rmi.server.UnicastServerRef.dispatch(UnicastServerRef.java:323)
at sun.rmi.transport.Transport$1.run(Transport.java:200)
at sun.rmi.transport.Transport$1.run(Transport.java:197)
at java.security.AccessController.doPrivileged(Native Method)
at sun.rmi.transport.Transport.serviceCall(Transport.java:196)
at sun.rmi.transport.tcp.TCPTransport.handleMessages(TCPTransport.java:568)
at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run0(TCPTransport.java:826)
at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.lambda$run$240(TCPTransport.java:683)
at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler$$Lambda$1/1241281054.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run(TCPTransport.java:682)
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)
at sun.rmi.transport.StreamRemoteCall.exceptionReceivedFromServer(StreamRemoteCall.java:276)
at sun.rmi.transport.StreamRemoteCall.executeCall(StreamRemoteCall.java:253)
at sun.rmi.server.UnicastRef.invoke(UnicastRef.java:162)
at com.sun.jmx.remote.internal.PRef.invoke(Unknown Source)
at javax.management.remote.rmi.RMIConnectionImpl_Stub.invoke(Unknown Source)
at javax.management.remote.rmi.RMIConnector$RemoteMBeanServerConnection.invoke(RMIConnector.java:1022)
What am I doing wrong?
Find below a snippet which shows a simpler way (instead of connecting via RMI to the running JVM) and the right syntax for the mbeanServer.invoke(...) method.
ObjectName objectName =new ObjectName("com.sun.management:type=DiagnosticCommand");
MBeanServer mbeanServer = ManagementFactory.getPlatformMBeanServer();
String operationName = "vmFlags";
Object[] params = new Object[1];
String[] signature = new String[]{String[].class.getName()};
String result = (String) mbeanServer.invoke(objectName, operationName,
params, signature);
System.out.printf("%s: %s%n", operationName, result);
output (the actual values are replaced with ...)
vmFlags: -XX:...

JSON String to List of objects

I've got the following JSON String which I receive. I try to convert the string to a List of objects using the given code here.
JSON String
{"hotelPromotions":[{"id":728,"version":1,"description":"Testing Discount","status":"ACTIVE","user":"MAHESHR","hotelId":245,"fromDate":1420070400000,"toDate":1420848000000,"hotelRoomTypeId":null,"travelAgentId":null,"roomTypeIds":[1138,1143,1137,1139,1140],"firstContractId":null,"secondContractId":null,"hotelIdTemp":null,"rateCategoryIds":[248],"ratePlanIds":[2108],"promotionType":"FREE_NIGHT","reservationInAdvanceValue":0,"reservationInAdvanceType":null,"noOfNights":2,"freeNights":1,"promotionAvailableDate":null,"discount":0,"availableMon":1,"availableTue":1,"availableWed":1,"availableThu":1,"availableFri":1,"availableSat":1,"availableSun":1,"reservationId":null,"multipleNights":"NO","resCreatedDate":null}],"hotelIBEDiscounts":[{"id":461,"version":1,"description":"nsg coupon","status":"ACTIVE","user":"MAHESHR","hotelId":245,"fromDate":1414627200000,"toDate":1419984000000,"hotelName":"The Wallawwa","roomTypeIds":[1138,1143],"rateCategoryIds":[248],"ratePlanIds":[],"discount":20,"availableMon":1,"availableTue":1,"availableWed":1,"availableThu":1,"availableFri":1,"availableSat":1,"availableSun":1,"discountType":"COUPONS","noOfCoupons":"10","couponsType":"UNIQUE"}]}
Convertion Code
List<HotelPromotionDTO> hotelPromotionDTOs = new ArrayList<HotelPromotionDTO>();
ParameterSupport parameterSupport = externalConnector.getCrsParameters();
//Get Server IP from Parameters
String serverIp = parameterSupport.getParam(CRSEntryParameterConstants.EXTERNAL_URL);;
String url = ApplicationWebURLConstants.HTTP_URL+""+serverIp+"/"+ApplicationWebURLConstants.GET_HOTEL_PROMO_AND_DISC_BY_DATES;
ObjectMapper objectMapper = new ObjectMapper();
objectMapper.configure(SerializationFeature.INDENT_OUTPUT, true);
StringWriter stringEmp = new StringWriter();
final DateFormat df = new SimpleDateFormat(DateConstants.JSON_DATE_FORMAT);
objectMapper.setDateFormat(df);
try {
objectMapper.writeValue(stringEmp, searchCriteria);
} catch (JsonGenerationException e) {
LOG.error("JsonGenerationException :::: ",e);
} catch (JsonMappingException e) {
LOG.error("JsonMappingException :::: ",e);
} catch (IOException e) {
LOG.error("IOException :::: ",e);
}
String jsonString = stringEmp.toString();
ClientResponse response = WebServiceUtil.postRequest(url, jsonString);
String output = response.getEntity(String.class);
//DeSerialization of response data to IBEDiscountCouponValidateResultDTO type
objectMapper = new ObjectMapper();
objectMapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
try {
hotelPromotionDTOs = objectMapper.readValue(output, objectMapper.getTypeFactory().constructCollectionType(List.class, HotelPromotionDTO.class));
} catch (JsonParseException e) {
LOG.error("JsonParseException on Deserialization :::: ",e);
} catch (JsonMappingException e) {
LOG.error("JsonMappingException on Deserialization :::: ",e);
} catch (IOException e) {
LOG.error("IOException on Deserialization :::: ",e);
}
return hotelPromotionDTOs;
When I execute the code I get the following error.
2014-12-30 06:27:11,527 ERROR [com.jkcs.zhara.ext.integration.client.impl.ApplicationConnectorZharaImpl] (http-8647-6:) JsonMappingException on Deserialization ::::
com.fasterxml.jackson.databind.JsonMappingException: Can not deserialize instance of java.util.ArrayList out of START_OBJECT token
at [Source: java.io.StringReader#6343b54; line: 1, column: 1]
at com.fasterxml.jackson.databind.JsonMappingException.from(JsonMappingException.java:164)
at com.fasterxml.jackson.databind.DeserializationContext.mappingException(DeserializationContext.java:691)
at com.fasterxml.jackson.databind.DeserializationContext.mappingException(DeserializationContext.java:685)
at com.fasterxml.jackson.databind.deser.std.CollectionDeserializer.handleNonArray(CollectionDeserializer.java:256)
at com.fasterxml.jackson.databind.deser.std.CollectionDeserializer.deserialize(CollectionDeserializer.java:214)
at com.fasterxml.jackson.databind.deser.std.CollectionDeserializer.deserialize(CollectionDeserializer.java:204)
at com.fasterxml.jackson.databind.deser.std.CollectionDeserializer.deserialize(CollectionDeserializer.java:23)
at com.fasterxml.jackson.databind.ObjectMapper._readMapAndClose(ObjectMapper.java:2986)
at com.fasterxml.jackson.databind.ObjectMapper.readValue(ObjectMapper.java:2105)
at com.jkcs.zhara.ext.integration.client.impl.ApplicationConnectorZharaImpl.findHotelPromoAndDiscForIBEByCriteria(ApplicationConnectorZharaImpl.java:489)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:317)
at org.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint(ReflectiveMethodInvocation.java:183)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:150)
at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:110)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172)
at org.springframework.aop.aspectj.MethodInvocationProceedingJoinPoint.proceed(MethodInvocationProceedingJoinPoint.java:80)
at com.jkcs.zhara.service.platform.aspects.ServiceProfilerAspect.profile(ServiceProfilerAspect.java:56)
at sun.reflect.GeneratedMethodAccessor101.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at org.springframework.aop.aspectj.AbstractAspectJAdvice.invokeAdviceMethodWithGivenArgs(AbstractAspectJAdvice.java:621)
at org.springframework.aop.aspectj.AbstractAspectJAdvice.invokeAdviceMethod(AbstractAspectJAdvice.java:610)
at org.springframework.aop.aspectj.AspectJAroundAdvice.invoke(AspectJAroundAdvice.java:65)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172)
at org.springframework.aop.aspectj.AspectJAfterThrowingAdvice.invoke(AspectJAfterThrowingAdvice.java:55)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172)
at org.springframework.aop.interceptor.ExposeInvocationInterceptor.invoke(ExposeInvocationInterceptor.java:91)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172)
at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:204)
at $Proxy128.findHotelPromoAndDiscForIBEByCriteria(Unknown Source)
at com.jkcs.zhara.ext.integration.client.ApplicationConnectorFactoryServiceImpl.findHotelPromoAndDiscForIBEByCriteria(ApplicationConnectorFactoryServiceImpl.java:84)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:317)
at org.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint(ReflectiveMethodInvocation.java:183)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:150)
at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:110)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172)
at org.springframework.aop.aspectj.MethodInvocationProceedingJoinPoint.proceed(MethodInvocationProceedingJoinPoint.java:80)
at com.jkcs.zhara.service.platform.aspects.ServiceProfilerAspect.profile(ServiceProfilerAspect.java:56)
at sun.reflect.GeneratedMethodAccessor101.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at org.springframework.aop.aspectj.AbstractAspectJAdvice.invokeAdviceMethodWithGivenArgs(AbstractAspectJAdvice.java:621)
at org.springframework.aop.aspectj.AbstractAspectJAdvice.invokeAdviceMethod(AbstractAspectJAdvice.java:610)
at org.springframework.aop.aspectj.AspectJAroundAdvice.invoke(AspectJAroundAdvice.java:65)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172)
at org.springframework.aop.aspectj.AspectJAfterThrowingAdvice.invoke(AspectJAfterThrowingAdvice.java:55)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172)
at org.springframework.aop.interceptor.ExposeInvocationInterceptor.invoke(ExposeInvocationInterceptor.java:91)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172)
at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:204)
at $Proxy129.findHotelPromoAndDiscForIBEByCriteria(Unknown Source)
at com.jkcs.zhara.service.booking.internal.impl.BookingInternalServiceImpl.getAllHotelDataOnLoad(BookingInternalServiceImpl.java:263)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:317)
at org.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint(ReflectiveMethodInvocation.java:183)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:150)
at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:110)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172)
at org.springframework.aop.aspectj.MethodInvocationProceedingJoinPoint.proceed(MethodInvocationProceedingJoinPoint.java:80)
at com.jkcs.zhara.service.platform.aspects.ServiceProfilerAspect.profile(ServiceProfilerAspect.java:56)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at org.springframework.aop.aspectj.AbstractAspectJAdvice.invokeAdviceMethodWithGivenArgs(AbstractAspectJAdvice.java:621)
at org.springframework.aop.aspectj.AbstractAspectJAdvice.invokeAdviceMethod(AbstractAspectJAdvice.java:610)
at org.springframework.aop.aspectj.AspectJAroundAdvice.invoke(AspectJAroundAdvice.java:65)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172)
at org.springframework.aop.aspectj.AspectJAfterThrowingAdvice.invoke(AspectJAfterThrowingAdvice.java:55)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172)
at org.springframework.aop.interceptor.ExposeInvocationInterceptor.invoke(ExposeInvocationInterceptor.java:91)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172)
at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:204)
at $Proxy131.getAllHotelDataOnLoad(Unknown Source)
at com.jkcs.zhara.service.booking.ejb.impl.BookingServiceBean.getAllHotelDataOnLoad(BookingServiceBean.java:48)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:112)
at org.jboss.ejb3.interceptor.InvocationContextImpl.proceed(InvocationContextImpl.java:166)
at org.jboss.ejb3.interceptor.EJB3InterceptorsInterceptor.invoke(EJB3InterceptorsInterceptor.java:63)
at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
at org.jboss.ejb3.entity.TransactionScopedEntityManagerInterceptor.invoke(TransactionScopedEntityManagerInterceptor.java:54)
at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
at org.jboss.ejb3.AllowedOperationsInterceptor.invoke(AllowedOperationsInterceptor.java:47)
at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
at org.jboss.aspects.tx.TxPolicy.invokeInOurTx(TxPolicy.java:79)
at org.jboss.aspects.tx.TxInterceptor$Required.invoke(TxInterceptor.java:191)
at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
at org.jboss.aspects.tx.TxPropagationInterceptor.invoke(TxPropagationInterceptor.java:95)
at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
at org.jboss.ejb3.stateless.StatelessInstanceInterceptor.invoke(StatelessInstanceInterceptor.java:62)
at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
at org.jboss.aspects.security.AuthenticationInterceptor.invoke(AuthenticationInterceptor.java:77)
at org.jboss.ejb3.security.Ejb3AuthenticationInterceptor.invoke(Ejb3AuthenticationInterceptor.java:110)
at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
at org.jboss.ejb3.ENCPropagationInterceptor.invoke(ENCPropagationInterceptor.java:46)
at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
at org.jboss.ejb3.asynchronous.AsynchronousInterceptor.invoke(AsynchronousInterceptor.java:106)
at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
at org.jboss.ejb3.stateless.StatelessContainer.localInvoke(StatelessContainer.java:240)
at org.jboss.ejb3.stateless.StatelessContainer.localInvoke(StatelessContainer.java:210)
at org.jboss.ejb3.stateless.StatelessLocalProxy.invoke(StatelessLocalProxy.java:84)
at $Proxy73.getAllHotelDataOnLoad(Unknown Source)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at org.springframework.ejb.access.LocalSlsbInvokerInterceptor.invokeInContext(LocalSlsbInvokerInterceptor.java:71)
at org.springframework.ejb.access.AbstractSlsbInvokerInterceptor.invoke(AbstractSlsbInvokerInterceptor.java:189)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172)
at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:204)
at $Proxy117.getAllHotelDataOnLoad(Unknown Source)
at com.jkcs.zhara.web.booking.BookingController.getLandingPage(BookingController.java:205)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at org.springframework.web.method.support.InvocableHandlerMethod.invoke(InvocableHandlerMethod.java:219)
at org.springframework.web.method.support.InvocableHandlerMethod.invokeForRequest(InvocableHandlerMethod.java:132)
at org.springframework.web.servlet.mvc.method.annotation.ServletInvocableHandlerMethod.invokeAndHandle(ServletInvocableHandlerMethod.java:104)
at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.invokeHandleMethod(RequestMappingHandlerAdapter.java:745)
at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.handleInternal(RequestMappingHandlerAdapter.java:686)
at org.springframework.web.servlet.mvc.method.AbstractHandlerMethodAdapter.handle(AbstractHandlerMethodAdapter.java:80)
at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:925)
at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:856)
at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:920)
at org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:816)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:690)
at org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:801)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFilter.java:96)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:230)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:175)
at org.jboss.web.tomcat.security.SecurityAssociationValve.invoke(SecurityAssociationValve.java:182)
at org.jboss.web.tomcat.service.session.ClusteredSessionValve.invoke(ClusteredSessionValve.java:97)
at org.jboss.web.tomcat.service.session.JvmRouteValve.invoke(JvmRouteValve.java:84)
at org.jboss.web.tomcat.security.JaccContextValve.invoke(JaccContextValve.java:84)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
at org.jboss.web.tomcat.service.jca.CachedConnectionValve.invoke(CachedConnectionValve.java:157)
at org.jboss.web.tomcat.service.sso.ClusteredSingleSignOn.invoke(ClusteredSingleSignOn.java:638)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:262)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:844)
at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:583)
at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:446)
at java.lang.Thread.run(Thread.java:662)
I tried using the TypeReference solution but it also gave me the above exception. It would be a great help if any one could identify the error I'm doing!
Your JSON matches an object (see HotelPromotionList below), not a list.
class HotelPromotionList {
List<HotelPromotion> hotelPromotions;
}
class HotelPromotion {
int id;
int version;
String description;
String status; // might be an enum
// ...
}
This works for me, use it for different types, hope this will help
public class RestMapper
{
private ObjectMapper objectMapper;
public <T> List<T> stringJsonToObject( String json, Class<T> objectType )
{
List<T> resultList = new LinkedList<T>();
ListOfObjects<T> arrObject;
try
{
arrObject = objectMapper.readValue( json, ListOfObjects.class );
for ( int i = 0; i < arrObject.getBody().size(); i++ )
{
T singleObject = objectMapper.convertValue( arrObject.getBody().get( i ), objectType );
resultList.add( singleObject );
}
}
catch ( IOException e )
{
e.printStackTrace();
}
return resultList;
}
static class ListOfObjects<T>
{
private List<T> body;
public ListOfObjects()
{
}
public void setBody( List<T> body )
{
this.body = body;
}
public List<T> getBody()
{
return body;
}
}

Another entities-cannot-be-cast-to-javassist-util-proxy-proxy

Following thread [entities cannot be cast to javassist.util.proxy.Proxy, i do have now a server side error ( tks thomas)
I wasn't able to face the real problem within my app.
java.lang.ClassCastException: org.nit.persistance.entities.Manufacturers_.$$_javassist_3 cannot be cast to javassist.util.proxy.Proxy
at org.hibernate.proxy.pojo.javassist.JavassistLazyInitializer.getProxy(JavassistLazyInitializer.java:148)
at org.hibernate.proxy.pojo.javassist.JavassistProxyFactory.getProxy(JavassistProxyFactory.java:73)
at org.hibernate.tuple.entity.AbstractEntityTuplizer.createProxy(AbstractEntityTuplizer.java:758)
at org.hibernate.persister.entity.AbstractEntityPersister.createProxy(AbstractEntityPersister.java:4419)
at org.hibernate.event.internal.DefaultLoadEventListener.createProxyIfNecessary(DefaultLoadEventListener.java:333)
at org.hibernate.event.internal.DefaultLoadEventListener.proxyOrLoad(DefaultLoadEventListener.java:259)
at org.hibernate.event.internal.DefaultLoadEventListener.onLoad(DefaultLoadEventListener.java:151)
at org.hibernate.internal.SessionImpl.fireLoad(SessionImpl.java:1017)
at org.hibernate.internal.SessionImpl.internalLoad(SessionImpl.java:944)
at org.hibernate.type.EntityType.resolveIdentifier(EntityType.java:671)
at org.hibernate.type.EntityType.resolve(EntityType.java:489)
at org.hibernate.engine.internal.TwoPhaseLoad.doInitializeEntity(TwoPhaseLoad.java:168)
at org.hibernate.engine.internal.TwoPhaseLoad.initializeEntity(TwoPhaseLoad.java:137)
at org.hibernate.loader.Loader.initializeEntitiesAndCollections(Loader.java:1112)
at org.hibernate.loader.Loader.processResultSet(Loader.java:969)
at org.hibernate.loader.Loader.doQuery(Loader.java:917)
at org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:348)
at org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:318)
at org.hibernate.loader.Loader.loadEntity(Loader.java:2143)
at org.hibernate.loader.entity.AbstractEntityLoader.load(AbstractEntityLoader.java:82)
at org.hibernate.loader.entity.AbstractEntityLoader.load(AbstractEntityLoader.java:72)
at org.hibernate.persister.entity.AbstractEntityPersister.load(AbstractEntityPersister.java:3939)
at org.hibernate.event.internal.DefaultLoadEventListener.loadFromDatasource(DefaultLoadEventListener.java:461)
at org.hibernate.event.internal.DefaultLoadEventListener.doLoad(DefaultLoadEventListener.java:430)
at org.hibernate.event.internal.DefaultLoadEventListener.load(DefaultLoadEventListener.java:207)
at org.hibernate.event.internal.DefaultLoadEventListener.proxyOrLoad(DefaultLoadEventListener.java:263)
at org.hibernate.event.internal.DefaultLoadEventListener.onLoad(DefaultLoadEventListener.java:151)
at org.hibernate.internal.SessionImpl.fireLoad(SessionImpl.java:1017)
at org.hibernate.internal.SessionImpl.access$2000(SessionImpl.java:173)
at org.hibernate.internal.SessionImpl$IdentifierLoadAccessImpl.load(SessionImpl.java:2413)
at org.hibernate.internal.SessionImpl.get(SessionImpl.java:913)
at org.nit.persistance.dao.impl.FichesImpl.readbyPK(FichesImpl.java:24)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:317)
at org.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint(ReflectiveMethodInvocation.java:183)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:150)
at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:110)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172)
at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:204)
at com.sun.proxy.$Proxy13.readbyPK(Unknown Source)
at org.nit.server.CEM.CEMFiches.fetch(CEMFiches.java:52)
at org.nit.server.service.FichesService.fetch(FichesService.java:11)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at com.google.web.bindery.requestfactory.server.ReflectiveServiceLayer.invoke(ReflectiveServiceLayer.java:182)
at com.google.web.bindery.requestfactory.server.ServiceLayerDecorator.invoke(ServiceLayerDecorator.java:111)
at com.google.web.bindery.requestfactory.server.ServiceLayerDecorator.invoke(ServiceLayerDecorator.java:111)
at com.google.web.bindery.requestfactory.server.SimpleRequestProcessor.processInvocationMessages(SimpleRequestProcessor.java:463)
at com.google.web.bindery.requestfactory.server.SimpleRequestProcessor.process(SimpleRequestProcessor.java:233)
at com.google.web.bindery.requestfactory.server.SimpleRequestProcessor.process(SimpleRequestProcessor.java:135)
at com.google.web.bindery.requestfactory.server.RequestFactoryServlet.doPost(RequestFactoryServlet.java:133)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:637)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
at org.mortbay.jetty.servlet.ServletHolder.handle(ServletHolder.java:487)
at org.mortbay.jetty.servlet.ServletHandler.handle(ServletHandler.java:362)
at org.mortbay.jetty.security.SecurityHandler.handle(SecurityHandler.java:216)
at org.mortbay.jetty.servlet.SessionHandler.handle(SessionHandler.java:181)
at org.mortbay.jetty.handler.ContextHandler.handle(ContextHandler.java:729)
at org.mortbay.jetty.webapp.WebAppContext.handle(WebAppContext.java:405)
at org.mortbay.jetty.handler.HandlerWrapper.handle(HandlerWrapper.java:152)
at org.mortbay.jetty.handler.RequestLogHandler.handle(RequestLogHandler.java:49)
at org.mortbay.jetty.handler.HandlerWrapper.handle(HandlerWrapper.java:152)
at org.mortbay.jetty.Server.handle(Server.java:324)
at org.mortbay.jetty.HttpConnection.handleRequest(HttpConnection.java:505)
at org.mortbay.jetty.HttpConnection$RequestHandler.content(HttpConnection.java:843)
at org.mortbay.jetty.HttpParser.parseNext(HttpParser.java:647)
at org.mortbay.jetty.HttpParser.parseAvailable(HttpParser.java:211)
at org.mortbay.jetty.HttpConnection.handle(HttpConnection.java:380)
at org.mortbay.io.nio.SelectChannelEndPoint.run(SelectChannelEndPoint.java:395)
at org.mortbay.thread.QueuedThreadPool$PoolThread.run(QueuedThreadPool.java:488)java.lang.ClassCastException: org.nit.persistance.entitesManufacturers_.$$_javassist_3 cannot be cast to javassist.util.proxy.Proxy
at org.hibernate.proxy.pojo.javassist.JavassistLazyInitializer.getProxy(JavassistLazyInitializer.java:148)
at org.hibernate.proxy.pojo.javassist.JavassistProxyFactory.getProxy(JavassistProxyFactory.java:73)
at org.hibernate.tuple.entity.AbstractEntityTuplizer.createProxy(AbstractEntityTuplizer.java:758)
at org.hibernate.persister.entity.AbstractEntityPersister.createProxy(AbstractEntityPersister.java:4419)
at org.hibernate.event.internal.DefaultLoadEventListener.createProxyIfNecessary(DefaultLoadEventListener.java:333)
at org.hibernate.event.internal.DefaultLoadEventListener.proxyOrLoad(DefaultLoadEventListener.java:259)
at org.hibernate.event.internal.DefaultLoadEventListener.onLoad(DefaultLoadEventListener.java:151)
at org.hibernate.internal.SessionImpl.fireLoad(SessionImpl.java:1017)
at org.hibernate.internal.SessionImpl.internalLoad(SessionImpl.java:944)
at org.hibernate.type.EntityType.resolveIdentifier(EntityType.java:671)
at org.hibernate.type.EntityType.resolve(EntityType.java:489)
at org.hibernate.engine.internal.TwoPhaseLoad.doInitializeEntity(TwoPhaseLoad.java:168)
at org.hibernate.engine.internal.TwoPhaseLoad.initializeEntity(TwoPhaseLoad.java:137)
at org.hibernate.loader.Loader.initializeEntitiesAndCollections(Loader.java:1112)
at org.hibernate.loader.Loader.processResultSet(Loader.java:969)
at org.hibernate.loader.Loader.doQuery(Loader.java:917)
at org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:348)
at org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:318)
at org.hibernate.loader.Loader.loadEntity(Loader.java:2143)
at org.hibernate.loader.entity.AbstractEntityLoader.load(AbstractEntityLoader.java:82)
at org.hibernate.loader.entity.AbstractEntityLoader.load(AbstractEntityLoader.java:72)
at org.hibernate.persister.entity.AbstractEntityPersister.load(AbstractEntityPersister.java:3939)
at org.hibernate.event.internal.DefaultLoadEventListener.loadFromDatasource(DefaultLoadEventListener.java:461)
at org.hibernate.event.internal.DefaultLoadEventListener.doLoad(DefaultLoadEventListener.java:430)
at org.hibernate.event.internal.DefaultLoadEventListener.load(DefaultLoadEventListener.java:207)
at org.hibernate.event.internal.DefaultLoadEventListener.proxyOrLoad(DefaultLoadEventListener.java:263)
at org.hibernate.event.internal.DefaultLoadEventListener.onLoad(DefaultLoadEventListener.java:151)
at org.hibernate.internal.SessionImpl.fireLoad(SessionImpl.java:1017)
at org.hibernate.internal.SessionImpl.access$2000(SessionImpl.java:173)
at org.hibernate.internal.SessionImpl$IdentifierLoadAccessImpl.load(SessionImpl.java:2413)
at org.hibernate.internal.SessionImpl.get(SessionImpl.java:913)
at org.nit.persistance.dao.impl.FichesImpl.readbyPK(FichesImpl.java:24)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:317)
at org.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint(ReflectiveMethodInvocation.java:183)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:150)
at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:110)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172)
at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:204)
at com.sun.proxy.$Proxy13.readbyPK(Unknown Source)
at org.nit.server.CEM.CEMFiches.fetch(CEMFiches.java:52)
at org.nit.server.service.FichesService.fetch(FichesService.java:11)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at com.google.web.bindery.requestfactory.server.ReflectiveServiceLayer.invoke(ReflectiveServiceLayer.java:182)
at com.google.web.bindery.requestfactory.server.ServiceLayerDecorator.invoke(ServiceLayerDecorator.java:111)
at com.google.web.bindery.requestfactory.server.ServiceLayerDecorator.invoke(ServiceLayerDecorator.java:111)
at com.google.web.bindery.requestfactory.server.SimpleRequestProcessor.processInvocationMessages(SimpleRequestProcessor.java:463)
at com.google.web.bindery.requestfactory.server.SimpleRequestProcessor.process(SimpleRequestProcessor.java:233)
at com.google.web.bindery.requestfactory.server.SimpleRequestProcessor.process(SimpleRequestProcessor.java:135)
at com.google.web.bindery.requestfactory.server.RequestFactoryServlet.doPost(RequestFactoryServlet.java:133)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:637)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
at org.mortbay.jetty.servlet.ServletHolder.handle(ServletHolder.java:487)
at org.mortbay.jetty.servlet.ServletHandler.handle(ServletHandler.java:362)
at org.mortbay.jetty.security.SecurityHandler.handle(SecurityHandler.java:216)
at org.mortbay.jetty.servlet.SessionHandler.handle(SessionHandler.java:181)
at org.mortbay.jetty.handler.ContextHandler.handle(ContextHandler.java:729)
at org.mortbay.jetty.webapp.WebAppContext.handle(WebAppContext.java:405)
at org.mortbay.jetty.handler.HandlerWrapper.handle(HandlerWrapper.java:152)
at org.mortbay.jetty.handler.RequestLogHandler.handle(RequestLogHandler.java:49)
at org.mortbay.jetty.handler.HandlerWrapper.handle(HandlerWrapper.java:152)
at org.mortbay.jetty.Server.handle(Server.java:324)
at org.mortbay.jetty.HttpConnection.handleRequest(HttpConnection.java:505)
at org.mortbay.jetty.HttpConnection$RequestHandler.content(HttpConnection.java:843)
at org.mortbay.jetty.HttpParser.parseNext(HttpParser.java:647)
at org.mortbay.jetty.HttpParser.parseAvailable(HttpParser.java:211)
at org.mortbay.jetty.HttpConnection.handle(HttpConnection.java:380)
at org.mortbay.io.nio.SelectChannelEndPoint.run(SelectChannelEndPoint.java:395)
at org.mortbay.thread.QueuedThreadPool$PoolThread.run(QueuedThreadPool.java:488)
What does this part means ?
at com.sun.proxy.$Proxy13.readbyPK(Unknown Source)
at org.nit.server.CEM.CEMFiches.fetch(CEMFiches.java:52)
at org.nit.server.service.FichesService.fetch(FichesService.java:11)
Error is on Manufacturers entity, but I am working on Fiches.
Fiches is linked by a many-to-one relation with References
References is linked by a many-to-one relation with Products
Products is linked by a many-to-one relation with Manufacturers.
Could it be a problem with one of my proxies ?
CEMFiches : ( Line 52 is return fichesDAO.readbyPK(fichesPK);)
public static Fiches fetch (String metier, String sitegeo, String cptdossier, Integer numligne) {
if (fichesDAO == null) {
HttpServletRequest request = RequestFactoryServlet.getThreadLocalRequest();
ApplicationContext context = WebApplicationContextUtils.getWebApplicationContext(request.getSession().getServletContext());
fichesDAO =context.getBean(IFichesDAO.class);
}
try {
FichesPK fichesPK = new FichesPK(metier,sitegeo, cptdossier, numligne);
return fichesDAO.readbyPK(fichesPK);
} catch (PersistanceException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
return null;
}
IfichesDAO is ( #transactional is used )
public interface IFichesDAO {
#Transactional(readOnly=true)
public void save(Fiches fiches) throws PersistanceException;
public Fiches readbyPK(FichesPK fichesPK) throws PersistanceException;
}
FichesImpl is
#Transactional(readOnly=true)
public Fiches readbyPK(FichesPK fichesPK){
return (Fiches)getSessionFactory().getCurrentSession().get(Fiches.class, fichesPK);
}
FichesService :
public class FichesService
{
public Fiches fetch(FichesPK id) { return CEMFiches.fetch(id); }
public FichesPK fetchPK(FichesPK id) { return CEMFiches.fetchPK(id); }
public Fiches fetch(String metier, String sitegeo, String cptdossier, Integer numligne) { return CEMFiches.fetch(metier, sitegeo, cptdossier, numligne); }
}
I also hit this issue while attempting to render an entity as JSON using Spring's #ResponseBody annotation. The issue turned out to be a relationship annotated as #ManyToOne with a FetchType of LAZY. The error message was not at all helpful. Switching to EAGER fetch solved the problem.
It may be helpful to note that in my case, the target entity also had a relationship of #ManyToOne which was recursive (target table had a foreign key to itself) which was also mapped as LAZY. Both relationships had to be switched to EAGER to get the problem resolved.
I encountered the same error and the strange thing is that all the other entities in my project run ok, except one. According to Boris the Spider's suggestion, I checked my project and found that there is a jar called weld-osgi-bundle.jar(in theJava EE 6 Libraries, provided by myEclipse10.0) contains some javassist code which may be conflict with javassist-3.18.1-GA.jarin my web libraries. So I removed it, and the problem gets solved.
So I ran into this issue, and I thought I would add some additional details for those who might have the same problem.
I had a collection of dependencies, and one imported org.javassist:javassist:3.18.1-GA, while the other imported javassist:javassist:3.11.0.GA.
Because of the different groups (it would seem that javassist:javassist became org.javassist:javassist), the build tool wasn't excluding one in favour of the other, and my WAR file had both.
I had to manually exclude the old javassist dependency, and once it was removed everything was fine.

Calling SSRS 2008 web service from Java

I am trying to implement a Java Spring application that will display SSRS reports. I have been following this tutorial: http://blogs.msdn.com/b/christophputz/archive/2010/05/07/accessing-ms-reporting-services-with-java.aspx. But at a certain point I ran onto a problem.
I downloaded the latest version of Metro wsimport (wsimport version "2.2.8").
I generate the webservices with the following commands:
wsimport -s -extension src http://devwin/reports/ReportExecution2005.asmx?wsdl
parsing WSDL...
[WARNING] SOAP port "ReportExecutionServiceSoap12": uses a non-standard SOAP 1.2 binding line 1885 of http://devwin/reports/ReportExecution2005.asmx?wsdl
Generating code...
Compiling code...
wsimport -s src -extension http://devwin/reports/ReportService2005.asmx?wsdl
parsing WSDL...
[WARNING] SOAP port "ReportingService2005Soap12": uses a non-standard SOAP 1.2 binding. line 5841 of http://devwin/reports/ReportService2005.asmx?wsdl
Generating code...
Compiling code...
I imported the generated source code (/src only because of the bug mentioned in the topic).
I used the following maven dependency
<dependency>
<groupId>com.sun.xml.ws</groupId>
<artifactId>jaxws-rt</artifactId>
<version>2.2.8</version>
</dependency>
Here is my class that calls the report:
import java.util.List;
import javax.xml.ws.BindingProvider;
import javax.xml.ws.Holder;
import com.iphos.rankingcheck.entity.Report;
import com.microsoft.schemas.sqlserver._2005._06._30.reporting.reportingservices.ArrayOfParameterValue;
import com.microsoft.schemas.sqlserver._2005._06._30.reporting.reportingservices.ArrayOfString;
import com.microsoft.schemas.sqlserver._2005._06._30.reporting.reportingservices.ArrayOfWarning;
import com.microsoft.schemas.sqlserver._2005._06._30.reporting.reportingservices.ExecutionHeader;
import com.microsoft.schemas.sqlserver._2005._06._30.reporting.reportingservices.ExecutionInfo;
import com.microsoft.schemas.sqlserver._2005._06._30.reporting.reportingservices.ParameterValue;
import com.microsoft.schemas.sqlserver._2005._06._30.reporting.reportingservices.ReportExecutionService;
import com.microsoft.schemas.sqlserver._2005._06._30.reporting.reportingservices.ReportExecutionServiceSoap;
import com.sun.xml.ws.developer.WSBindingProvider;
public class ReportServiceCaller {
public static void callReportWS(Report report) {
String reportPath = "/Path/Report";
String format = "HTML4.0";
String historyID = null;
String devInfo = "<DeviceInfo><Toolbar>False</Toolbar><HTMLFragment>True</HTMLFragment></DeviceInfo>";
String executionID = null;
Holder<String> extension = null;
Holder<String> mimeType = null;
Holder<String> encoding = null;
Holder<ArrayOfWarning> warnings = null;
Holder<ArrayOfString> streamIDs = null;
Holder<byte[]> result = new Holder<byte[]>();
ReportExecutionService res = new ReportExecutionService();
ReportExecutionServiceSoap ress = res.getReportExecutionServiceSoap();
BindingProvider bp = (BindingProvider)ress;
WSBindingProvider wsbp = (WSBindingProvider)ress;
// Sessions erlauben
bp.getRequestContext().put(BindingProvider.SESSION_MAINTAIN_PROPERTY, true);
ExecutionInfo execInfo = new ExecutionInfo();
// Parameterliste erzeugen
ArrayOfParameterValue apv = new ArrayOfParameterValue();
List<ParameterValue> apvList = apv.getParameterValue();
ParameterValue param0 = new ParameterValue();
param0.setName("Project");
param0.setValue(report.getProject().getProjectName());
apvList.add(param0);
// Report vorbereiten
execInfo = ress.loadReport(reportPath, historyID);
// ExecutionID für den nächsten Aufruf merken
executionID = execInfo.getExecutionID();
bp.getRequestContext().put("sessionID", executionID);
// ExecutionHeader Element erzeugen und es für den nächsten Aufruf
// and den WSBindingProvider übergeben
ExecutionHeader eh = new ExecutionHeader();
eh.setExecutionID(executionID);
wsbp.setOutboundHeaders(eh);
// Parameter an den Report übergeben
ress.setExecutionParameters(apv, "en-us");
// Report anfordern
ress.render(format, devInfo, result, extension, mimeType, encoding, warnings, streamIDs);
// Ergebnis des Aufrufs ausgeben
String resultString = new String(result.value);
}
}
When I try to run the report I get the following exception:
org.springframework.web.util.NestedServletException: Handler processing failed; nested exception is java.lang.NoSuchMethodError: com.sun.xml.bind.v2.runtime.MarshallerImpl.marshal(Ljava/lang/Object;Ljava/io/OutputStream;Ljavax/xml/namespace/NamespaceContext;)V
org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:839)
org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:719)
org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:669)
org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:574)
javax.servlet.http.HttpServlet.service(HttpServlet.java:621)
javax.servlet.http.HttpServlet.service(HttpServlet.java:722)
org.springframework.orm.jpa.support.OpenEntityManagerInViewFilter.doFilterInternal(OpenEntityManagerInViewFilter.java:113)
org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:76)
org.springframework.web.filter.HiddenHttpMethodFilter.doFilterInternal(HiddenHttpMethodFilter.java:77)
org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:76)
org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:88)
org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:76)
root cause
java.lang.NoSuchMethodError: com.sun.xml.bind.v2.runtime.MarshallerImpl.marshal(Ljava/lang/Object;Ljava/io/OutputStream;Ljavax/xml/namespace/NamespaceContext;)V
com.sun.xml.ws.db.glassfish.MarshallerBridge.marshal(MarshallerBridge.java:86)
com.sun.xml.bind.api.Bridge.marshal(Bridge.java:105)
com.sun.xml.ws.message.jaxb.JAXBHeader.writeTo(JAXBHeader.java:201)
com.sun.xml.ws.message.AbstractMessageImpl.writeTo(AbstractMessageImpl.java:148)
com.sun.xml.ws.api.message.MessageWrapper.writeTo(MessageWrapper.java:230)
com.sun.xml.ws.encoding.StreamSOAPCodec.encode(StreamSOAPCodec.java:134)
com.sun.xml.ws.encoding.SOAPBindingCodec.encode(SOAPBindingCodec.java:242)
com.sun.xml.ws.transport.http.client.HttpTransportPipe.process(HttpTransportPipe.java:223)
com.sun.xml.ws.transport.http.client.HttpTransportPipe.processRequest(HttpTransportPipe.java:143)
com.sun.xml.ws.transport.DeferredTransportPipe.processRequest(DeferredTransportPipe.java:110)
com.sun.xml.ws.api.pipe.Fiber.__doRun(Fiber.java:1136)
com.sun.xml.ws.api.pipe.Fiber._doRun(Fiber.java:1050)
com.sun.xml.ws.api.pipe.Fiber.doRun(Fiber.java:1019)
com.sun.xml.ws.api.pipe.Fiber.runSync(Fiber.java:877)
com.sun.xml.ws.client.Stub.process(Stub.java:464)
com.sun.xml.ws.client.sei.SEIStub.doProcess(SEIStub.java:174)
com.sun.xml.ws.client.sei.SyncMethodHandler.invoke(SyncMethodHandler.java:108)
com.sun.xml.ws.client.sei.SyncMethodHandler.invoke(SyncMethodHandler.java:91)
com.sun.xml.ws.client.sei.SEIStub.invoke(SEIStub.java:154)
com.sun.proxy.$Proxy93.setExecutionParameters(Unknown Source)
com.iphos.rankingcheck.util.ReportServiceCaller.callReportWS(ReportServiceCaller.java:79)
com.iphos.rankingcheck.controller.ReportController.display(ReportController.java:209)
sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
java.lang.reflect.Method.invoke(Method.java:601)
org.springframework.web.bind.annotation.support.HandlerMethodInvoker.invokeHandlerMethod(HandlerMethodInvoker.java:176)
org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter.invokeHandlerMethod(AnnotationMethodHandlerAdapter.java:436)
org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter.handle(AnnotationMethodHandlerAdapter.java:424)
org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:790)
org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:719)
org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:669)
org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:574)
javax.servlet.http.HttpServlet.service(HttpServlet.java:621)
javax.servlet.http.HttpServlet.service(HttpServlet.java:722)
org.springframework.orm.jpa.support.OpenEntityManagerInViewFilter.doFilterInternal(OpenEntityManagerInViewFilter.java:113)
org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:76)
org.springframework.web.filter.HiddenHttpMethodFilter.doFilterInternal(HiddenHttpMethodFilter.java:77)
org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:76)
org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:88)
org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:76)
I figured out that probably the implementation of that method is missing so I tried to search for a dependency to provide it. I found a few, but I was able to move from that exception only with that one:
<dependency>
<groupId>com.sun.xml.bind</groupId>
<artifactId>jaxb-impl</artifactId>
<version>2.2.7</version>
</dependency>
When I added it I got the following exception:
org.springframework.web.util.NestedServletException: Request processing failed; nested exception is javax.xml.ws.WebServiceException: com.sun.istack.XMLStreamException2: javax.xml.bind.JAXBException: class com.microsoft.schemas.sqlserver._2005._06._30.reporting.reportingservices.ExecutionHeader nor any of its super class is known to this context.
org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:681)
org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:574)
javax.servlet.http.HttpServlet.service(HttpServlet.java:621)
javax.servlet.http.HttpServlet.service(HttpServlet.java:722)
org.springframework.orm.jpa.support.OpenEntityManagerInViewFilter.doFilterInternal(OpenEntityManagerInViewFilter.java:113)
org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:76)
org.springframework.web.filter.HiddenHttpMethodFilter.doFilterInternal(HiddenHttpMethodFilter.java:77)
org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:76)
org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:88)
org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:76)
root cause
javax.xml.ws.WebServiceException: com.sun.istack.XMLStreamException2: javax.xml.bind.JAXBException: class com.microsoft.schemas.sqlserver._2005._06._30.reporting.reportingservices.ExecutionHeader nor any of its super class is known to this context.
com.sun.xml.ws.encoding.StreamSOAPCodec.encode(StreamSOAPCodec.java:137)
com.sun.xml.ws.encoding.SOAPBindingCodec.encode(SOAPBindingCodec.java:242)
com.sun.xml.ws.transport.http.client.HttpTransportPipe.process(HttpTransportPipe.java:223)
com.sun.xml.ws.transport.http.client.HttpTransportPipe.processRequest(HttpTransportPipe.java:143)
com.sun.xml.ws.transport.DeferredTransportPipe.processRequest(DeferredTransportPipe.java:110)
com.sun.xml.ws.api.pipe.Fiber.__doRun(Fiber.java:1136)
com.sun.xml.ws.api.pipe.Fiber._doRun(Fiber.java:1050)
com.sun.xml.ws.api.pipe.Fiber.doRun(Fiber.java:1019)
com.sun.xml.ws.api.pipe.Fiber.runSync(Fiber.java:877)
com.sun.xml.ws.client.Stub.process(Stub.java:464)
com.sun.xml.ws.client.sei.SEIStub.doProcess(SEIStub.java:174)
com.sun.xml.ws.client.sei.SyncMethodHandler.invoke(SyncMethodHandler.java:108)
com.sun.xml.ws.client.sei.SyncMethodHandler.invoke(SyncMethodHandler.java:91)
com.sun.xml.ws.client.sei.SEIStub.invoke(SEIStub.java:154)
com.sun.proxy.$Proxy93.setExecutionParameters(Unknown Source)
com.iphos.rankingcheck.util.ReportServiceCaller.callReportWS(ReportServiceCaller.java:79)
com.iphos.rankingcheck.controller.ReportController.display(ReportController.java:209)
sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
java.lang.reflect.Method.invoke(Method.java:601)
org.springframework.web.bind.annotation.support.HandlerMethodInvoker.invokeHandlerMethod(HandlerMethodInvoker.java:176)
org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter.invokeHandlerMethod(AnnotationMethodHandlerAdapter.java:436)
org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter.handle(AnnotationMethodHandlerAdapter.java:424)
org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:790)
org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:719)
org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:669)
org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:574)
javax.servlet.http.HttpServlet.service(HttpServlet.java:621)
javax.servlet.http.HttpServlet.service(HttpServlet.java:722)
org.springframework.orm.jpa.support.OpenEntityManagerInViewFilter.doFilterInternal(OpenEntityManagerInViewFilter.java:113)
org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:76)
org.springframework.web.filter.HiddenHttpMethodFilter.doFilterInternal(HiddenHttpMethodFilter.java:77)
org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:76)
org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:88)
org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:76)
root cause
com.sun.istack.XMLStreamException2: javax.xml.bind.JAXBException: class com.microsoft.schemas.sqlserver._2005._06._30.reporting.reportingservices.ExecutionHeader nor any of its super class is known to this context.
com.sun.xml.ws.message.jaxb.JAXBHeader.writeTo(JAXBHeader.java:206)
com.sun.xml.ws.message.AbstractMessageImpl.writeTo(AbstractMessageImpl.java:148)
com.sun.xml.ws.api.message.MessageWrapper.writeTo(MessageWrapper.java:230)
com.sun.xml.ws.encoding.StreamSOAPCodec.encode(StreamSOAPCodec.java:134)
com.sun.xml.ws.encoding.SOAPBindingCodec.encode(SOAPBindingCodec.java:242)
com.sun.xml.ws.transport.http.client.HttpTransportPipe.process(HttpTransportPipe.java:223)
com.sun.xml.ws.transport.http.client.HttpTransportPipe.processRequest(HttpTransportPipe.java:143)
com.sun.xml.ws.transport.DeferredTransportPipe.processRequest(DeferredTransportPipe.java:110)
com.sun.xml.ws.api.pipe.Fiber.__doRun(Fiber.java:1136)
com.sun.xml.ws.api.pipe.Fiber._doRun(Fiber.java:1050)
com.sun.xml.ws.api.pipe.Fiber.doRun(Fiber.java:1019)
com.sun.xml.ws.api.pipe.Fiber.runSync(Fiber.java:877)
com.sun.xml.ws.client.Stub.process(Stub.java:464)
com.sun.xml.ws.client.sei.SEIStub.doProcess(SEIStub.java:174)
com.sun.xml.ws.client.sei.SyncMethodHandler.invoke(SyncMethodHandler.java:108)
com.sun.xml.ws.client.sei.SyncMethodHandler.invoke(SyncMethodHandler.java:91)
com.sun.xml.ws.client.sei.SEIStub.invoke(SEIStub.java:154)
com.sun.proxy.$Proxy93.setExecutionParameters(Unknown Source)
com.iphos.rankingcheck.util.ReportServiceCaller.callReportWS(ReportServiceCaller.java:79)
com.iphos.rankingcheck.controller.ReportController.display(ReportController.java:209)
sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
java.lang.reflect.Method.invoke(Method.java:601)
org.springframework.web.bind.annotation.support.HandlerMethodInvoker.invokeHandlerMethod(HandlerMethodInvoker.java:176)
org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter.invokeHandlerMethod(AnnotationMethodHandlerAdapter.java:436)
org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter.handle(AnnotationMethodHandlerAdapter.java:424)
org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:790)
org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:719)
org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:669)
org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:574)
javax.servlet.http.HttpServlet.service(HttpServlet.java:621)
javax.servlet.http.HttpServlet.service(HttpServlet.java:722)
org.springframework.orm.jpa.support.OpenEntityManagerInViewFilter.doFilterInternal(OpenEntityManagerInViewFilter.java:113)
org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:76)
org.springframework.web.filter.HiddenHttpMethodFilter.doFilterInternal(HiddenHttpMethodFilter.java:77)
org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:76)
org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:88)
org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:76)
root cause
javax.xml.bind.JAXBException: class com.microsoft.schemas.sqlserver._2005._06._30.reporting.reportingservices.ExecutionHeader nor any of its super class is known to this context.
com.sun.xml.bind.v2.runtime.JAXBContextImpl.getBeanInfo(JAXBContextImpl.java:593)
com.sun.xml.bind.v2.runtime.XMLSerializer.childAsRoot(XMLSerializer.java:482)
com.sun.xml.bind.v2.runtime.MarshallerImpl.write(MarshallerImpl.java:323)
com.sun.xml.bind.v2.runtime.MarshallerImpl.marshal(MarshallerImpl.java:173)
com.sun.xml.ws.db.glassfish.MarshallerBridge.marshal(MarshallerBridge.java:86)
com.sun.xml.bind.api.Bridge.marshal(Bridge.java:145)
com.sun.xml.ws.message.jaxb.JAXBHeader.writeTo(JAXBHeader.java:201)
com.sun.xml.ws.message.AbstractMessageImpl.writeTo(AbstractMessageImpl.java:148)
com.sun.xml.ws.api.message.MessageWrapper.writeTo(MessageWrapper.java:230)
com.sun.xml.ws.encoding.StreamSOAPCodec.encode(StreamSOAPCodec.java:134)
com.sun.xml.ws.encoding.SOAPBindingCodec.encode(SOAPBindingCodec.java:242)
com.sun.xml.ws.transport.http.client.HttpTransportPipe.process(HttpTransportPipe.java:223)
com.sun.xml.ws.transport.http.client.HttpTransportPipe.processRequest(HttpTransportPipe.java:143)
com.sun.xml.ws.transport.DeferredTransportPipe.processRequest(DeferredTransportPipe.java:110)
com.sun.xml.ws.api.pipe.Fiber.__doRun(Fiber.java:1136)
com.sun.xml.ws.api.pipe.Fiber._doRun(Fiber.java:1050)
com.sun.xml.ws.api.pipe.Fiber.doRun(Fiber.java:1019)
com.sun.xml.ws.api.pipe.Fiber.runSync(Fiber.java:877)
com.sun.xml.ws.client.Stub.process(Stub.java:464)
com.sun.xml.ws.client.sei.SEIStub.doProcess(SEIStub.java:174)
com.sun.xml.ws.client.sei.SyncMethodHandler.invoke(SyncMethodHandler.java:108)
com.sun.xml.ws.client.sei.SyncMethodHandler.invoke(SyncMethodHandler.java:91)
com.sun.xml.ws.client.sei.SEIStub.invoke(SEIStub.java:154)
com.sun.proxy.$Proxy93.setExecutionParameters(Unknown Source)
com.iphos.rankingcheck.util.ReportServiceCaller.callReportWS(ReportServiceCaller.java:79)
com.iphos.rankingcheck.controller.ReportController.display(ReportController.java:209)
sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
java.lang.reflect.Method.invoke(Method.java:601)
org.springframework.web.bind.annotation.support.HandlerMethodInvoker.invokeHandlerMethod(HandlerMethodInvoker.java:176)
org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter.invokeHandlerMethod(AnnotationMethodHandlerAdapter.java:436)
org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter.handle(AnnotationMethodHandlerAdapter.java:424)
org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:790)
org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:719)
org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:669)
org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:574)
javax.servlet.http.HttpServlet.service(HttpServlet.java:621)
javax.servlet.http.HttpServlet.service(HttpServlet.java:722)
org.springframework.orm.jpa.support.OpenEntityManagerInViewFilter.doFilterInternal(OpenEntityManagerInViewFilter.java:113)
org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:76)
org.springframework.web.filter.HiddenHttpMethodFilter.doFilterInternal(HiddenHttpMethodFilter.java:77)
org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:76)
org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:88)
org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:76)
I tried adding other dependencies like: webservices-rt, webservices-osgi and others, but I was unable to resolve the issue.
Any suggestions would be apprecieated.
None of these error messages seem to be coming from RS side. If your goal is just to show report in your Java App, have you considered URL access to show reports (in any kind of application) ?
If you really need to use web service, I would recommend enabling verbose logging and HTTP logging on RS side to see what is that RS is really complaining about the request.
Here is solution using axis.
build.gradle
dependencies {
compile('commons-discovery:commons-discovery:0.5')
compile('org.apache.axis:axis:1.4')
compile('org.apache.axis:axis-jaxrpc:1.4')
compile('org.apache.axis:axis-saaj:1.4')
compile('axis:axis-wsdl4j:1.5.1')
axisGenAntTask 'org.apache.axis:axis-ant:1.4',
'org.apache.axis:axis:1.4',
'org.apache.axis:axis-jaxrpc:1.4',
'axis:axis-wsdl4j:1.5.1',
'commons-codec:commons-codec:1.3',
'commons-logging:commons-logging:1.1.1',
'commons-discovery:commons-discovery:0.2'
}
task genWsdlClasses {
doLast {
def destDir = file("${buildDir}/generated/src/main/java")
ant.taskdef(name: 'genClassesFromWSDL',
classname: 'org.apache.axis.tools.ant.wsdl.Wsdl2javaAntTask',
classpath: configurations.axisGenAntTask.asPath)
destDir.mkdirs()
ant.genClassesFromWSDL(url: "pathOrUrlToWsdl", output: destDir, username: "optionalUsername", password: "optionalPwd");
}
}
sourceSets {
generated {
java.srcDirs "${buildDir}/generated/src/main/java"
}
main {
compileClasspath += generated.output
runtimeClasspath += generated.output
}
test {
compileClasspath += generated.output
runtimeClasspath += generated.output
}
}
compileGeneratedJava {
dependsOn(genWsdlClasses)
classpath = configurations.compile
}
compileJava{
dependsOn(compileGeneratedJava)
source += sourceSets.generated.java
}
java code
public String getHtml(String reportPath, Map<String, String> reportParameters) {
try {
ReportExecutionService reportExecution = new ReportExecutionServiceLocator();
ReportExecutionServiceSoapStub ress = (ReportExecutionServiceSoapStub) reportExecution.getReportExecutionServiceSoap();
final ExecutionInfo info = ress.loadReport(reportPath, null);
final String executionId = info.getExecutionID();
SOAPHeaderElement sessionHeader = new SOAPHeaderElement(
"http://schemas.microsoft.com/sqlserver/2005/06/30/reporting/reportingservices",
"ExecutionHeader");
SOAPElement addChildElement = sessionHeader.addChildElement("ExecutionID");
addChildElement.addTextNode(executionId);
ress.setHeader(sessionHeader);
final ParameterValue[] parameters = new ParameterValue[reportParameters != null ? reportParameters.size() : 0];
if (reportParameters != null && !reportParameters.isEmpty()) {
int i = 0;
for (final String name : reportParameters.keySet()) {
final String value = reportParameters.get(name);
ParameterValue parameterValue = new ParameterValue();
parameterValue.setName(name);
parameterValue.setValue(value);
parameters[i++] = parameterValue;
}
}
ress.setExecutionParameters(parameters, "en-us");
String format = "HTML4.0";
String devInfo = "<DeviceInfo><Toolbar>False</Toolbar><HTMLFragment>True</HTMLFragment></DeviceInfo>";
final ByteArrayHolder result = new ByteArrayHolder();
final StringHolder extension = new StringHolder();
final StringHolder mimeType = new StringHolder("text/html");
final StringHolder encoding = new StringHolder(StandardCharsets.UTF_8.name());
final ArrayOfWarningHolder warnings = new ArrayOfWarningHolder();
final ArrayOfStringHolder streamIds = new ArrayOfStringHolder();
ress.render(format, devInfo, result, extension, mimeType, encoding, warnings, streamIds);
return new String(result.value);
} catch (Exception e) {
throw new RuntimeException("Report generation error", e);
}
}
I solved the problem by using a different tool than Metro. The right tool for the job was axis, axis-wsdl4j.

GWT serialization over RPC

I couldn't find a solution for this problem even after going through tons of blogs.
Yes, my model(POJOs) implement Serializable (tried with IsSerializable as well)
I had success earlier with RPCs but i dont know why am i getting this error now:
com.google.gwt.user.client.rpc.StatusCodeException: 500 The call failed on the server; see server log for details
at com.google.gwt.user.client.rpc.impl.RequestCallbackAdapter.onResponseReceived(RequestCallbackAdapter.java:209)
at com.google.gwt.http.client.Request.fireOnResponseReceived(Request.java:287)
at com.google.gwt.http.client.RequestBuilder$1.onReadyStateChange(RequestBuilder.java:395)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at com.google.gwt.dev.shell.MethodAdaptor.invoke(MethodAdaptor.java:103)
at com.google.gwt.dev.shell.MethodDispatch.invoke(MethodDispatch.java:71)
at com.google.gwt.dev.shell.OophmSessionHandler.invoke(OophmSessionHandler.java:172)
at com.google.gwt.dev.shell.BrowserChannelServer.reactToMessagesWhileWaitingForReturn(BrowserChannelServer.java:337)
at com.google.gwt.dev.shell.BrowserChannelServer.invokeJavascript(BrowserChannelServer.java:218)
at com.google.gwt.dev.shell.ModuleSpaceOOPHM.doInvoke(ModuleSpaceOOPHM.java:136)
at com.google.gwt.dev.shell.ModuleSpace.invokeNative(ModuleSpace.java:561)
at com.google.gwt.dev.shell.ModuleSpace.invokeNativeObject(ModuleSpace.java:269)
at com.google.gwt.dev.shell.JavaScriptHost.invokeNativeObject(JavaScriptHost.java:91)
at com.google.gwt.core.client.impl.Impl.apply(Impl.java)
at com.google.gwt.core.client.impl.Impl.entry0(Impl.java:213)
at sun.reflect.GeneratedMethodAccessor24.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at com.google.gwt.dev.shell.MethodAdaptor.invoke(MethodAdaptor.java:103)
at com.google.gwt.dev.shell.MethodDispatch.invoke(MethodDispatch.java:71)
at com.google.gwt.dev.shell.OophmSessionHandler.invoke(OophmSessionHandler.java:172)
at com.google.gwt.dev.shell.BrowserChannelServer.reactToMessages(BrowserChannelServer.java:292)
at com.google.gwt.dev.shell.BrowserChannelServer.processConnection(BrowserChannelServer.java:546)
at com.google.gwt.dev.shell.BrowserChannelServer.run(BrowserChannelServer.java:363)
at java.lang.Thread.run(Unknown Source)
Server Stack Trace:
Starting Jetty on port 8888
[WARN] Exception while dispatching incoming RPC call
com.google.gwt.user.server.rpc.UnexpectedException: Service method 'public abstract com.project.package.gwt.shared.User com.project.package.gwt.client.ProService.loginServer(java.lang.String,java.lang.String)' threw an unexpected exception: java.lang.NullPointerException
at com.google.gwt.user.server.rpc.RPC.encodeResponseForFailure(RPC.java:385)
at com.google.gwt.user.server.rpc.RPC.invokeAndEncodeResponse(RPC.java:588)
at com.google.gwt.user.server.rpc.RemoteServiceServlet.processCall(RemoteServiceServlet.java:208)
at com.google.gwt.user.server.rpc.RemoteServiceServlet.processPost(RemoteServiceServlet.java:248)
at com.google.gwt.user.server.rpc.AbstractRemoteServiceServlet.doPost(AbstractRemoteServiceServlet.java:62)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:637)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
at org.mortbay.jetty.servlet.ServletHolder.handle(ServletHolder.java:487)
at org.mortbay.jetty.servlet.ServletHandler.handle(ServletHandler.java:362)
at org.mortbay.jetty.security.SecurityHandler.handle(SecurityHandler.java:216)
at org.mortbay.jetty.servlet.SessionHandler.handle(SessionHandler.java:181)
at org.mortbay.jetty.handler.ContextHandler.handle(ContextHandler.java:729)
at org.mortbay.jetty.webapp.WebAppContext.handle(WebAppContext.java:405)
at org.mortbay.jetty.handler.HandlerWrapper.handle(HandlerWrapper.java:152)
at org.mortbay.jetty.handler.RequestLogHandler.handle(RequestLogHandler.java:49)
at org.mortbay.jetty.handler.HandlerWrapper.handle(HandlerWrapper.java:152)
at org.mortbay.jetty.Server.handle(Server.java:324)
at org.mortbay.jetty.HttpConnection.handleRequest(HttpConnection.java:505)
at org.mortbay.jetty.HttpConnection$RequestHandler.content(HttpConnection.java:843)
at org.mortbay.jetty.HttpParser.parseNext(HttpParser.java:647)
at org.mortbay.jetty.HttpParser.parseAvailable(HttpParser.java:211)
at org.mortbay.jetty.HttpConnection.handle(HttpConnection.java:380)
at org.mortbay.io.nio.SelectChannelEndPoint.run(SelectChannelEndPoint.java:395)
at org.mortbay.thread.QueuedThreadPool$PoolThread.run(QueuedThreadPool.java:488)
Caused by: java.lang.NullPointerException
at com.project.package.gwt.server.ProServiceImpl.loginServer(ProServiceImpl.java:85)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at com.google.gwt.user.server.rpc.RPC.invokeAndEncodeResponse(RPC.java:569)
... 22 more
Can`t i serialize Strings over the wire too?
And the null pointer exception is showing because the RPC is not succesfull. I expect an object to be returned if the RPC is successfull
Adding Source code
com.project.package.gwt.server.ProServiceImpl.loginServer.java
public User loginServer(String uname, String password) {
System.out.println("Making User Login Call to the server");
System.out.println("Username is : "+uname+" Password is : "+password);
return loginObj.validateLogin(uname, password);
}
validate login method, which validates an user
public User validateLogin(String username, String password) {
System.out.println("Inside Server/");
//ApplicationContext ac = new ClassPathXmlApplicationContext("jdbc-context.xml");
ApplicationContext ac = new ClassPathXmlApplicationContext("jdbc-context.xml");
DataSource dataSource = (DataSource) ac.getBean("dataSource");
JdbcTemplate jdbcTemplate = new JdbcTemplate(dataSource);
System.out.println("Inside Server/Login Handler");
String result = null;
String query = "SELECT emp_name FROM emp_name = ? AND emp_password = ?";
try {
result = jdbcTemplate.queryForObject(query, String.class);
} catch (EmptyResultDataAccessException e) {
// TODO: handle exception#
e.printStackTrace();
}
if (result == null) {
System.out.println("The result of the SQL query is null");
} else {
System.out.println("The result of the SQL query is " + result);
user.setUsername(result);
}
return user;
}
}
The control is not going inside the validate login method(Inside Server / is not printing) which means my RPC is failing and hence an NPE
It's 99% that your loginObj is null. Please make sure that it's true.
System.out.println(loginObj == null);
return loginObj.validateLogin(uname, password);
And give us your 85th line of the ProServiceImpl.java source code. How long can we wait?
Well you have a java.lang.NullPointerException
at com.project.package.gwt.server.ProtasServiceImpl.loginServer(ProtasServiceImpl.java:85)
You need to identify what is causing that.

Categories

Resources