I am created soap webservice in my server. And I want to call other service(In another server) from my soap service using httpClient with "POST" method. I used "httpclient-4.2.2.jar" and "httpcore-4.2.2.jar".
Code snippet:
public class User {
public static String addUser(String userEmail, String password) {
final String uri = "http://www.example.com/";
String requestParams = String.format("{\"userEmail\": \"%s\", \"password\": \"%s\"}", userEmail, password);
final HttpClient client = new DefaultHttpClient();
final HttpPost postMethod = new HttpPost(uri);
postMethod.setEntity(new StringEntity(requestParams, "utf-8"));
try {
final HttpResponse response = client.execute(postMethod);
final String responseData = EntityUtils.toString(response.getEntity(), "utf-8");
System.out.println(responseData);
} catch(final Exception e) {
e.printStackTrace();
}
return responseData;
}
}
When I call this menthod from another class using the following code.
User.addUser(userEmail, password);
Stacktrace:
java.lang.reflect.InvocationTargetException
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.apache.struts.actions.DispatchAction.dispatchMethod(DispatchAction.java:269)
at org.apache.struts.actions.DispatchAction.execute(DispatchAction.java:170)
at org.apache.struts.chain.commands.servlet.ExecuteAction.execute(ExecuteAction.java:58)
at org.apache.struts.chain.commands.AbstractExecuteAction.execute(AbstractExecuteAction.java:67)
at org.apache.struts.chain.commands.ActionCommandBase.execute(ActionCommandBase.java:51)
at org.apache.commons.chain.impl.ChainBase.execute(ChainBase.java:191)
at org.apache.commons.chain.generic.LookupCommand.execute(LookupCommand.java:305)
at org.apache.commons.chain.impl.ChainBase.execute(ChainBase.java:191)
at org.apache.struts.chain.ComposableRequestProcessor.process(ComposableRequestProcessor.java:283)
at org.apache.struts.action.ActionServlet.process(ActionServlet.java:1913)
at org.apache.struts.action.ActionServlet.doGet(ActionServlet.java:449)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:693)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:806)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
at org.apache.geronimo.tomcat.valve.DefaultSubjectValve.invoke(DefaultSubjectValve.java:56)
at org.apache.geronimo.tomcat.GeronimoStandardContext$SystemMethodValve.invoke(GeronimoStandardContext.java:406)
at org.apache.geronimo.tomcat.valve.GeronimoBeforeAfterValve.invoke(GeronimoBeforeAfterValve.java:47)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:555)
at org.apache.geronimo.tomcat.valve.ThreadCleanerValve.invoke(ThreadCleanerValve.java:40)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:298)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:852)
at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:588)
at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:489)
at java.lang.Thread.run(Thread.java:662)
Caused by: java.lang.VerifyError: Cannot inherit from final class
at java.lang.ClassLoader.defineClass1(Native Method)
at java.lang.ClassLoader.defineClassCond(ClassLoader.java:631)
at java.lang.ClassLoader.defineClass(ClassLoader.java:615)
at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:141)
at org.apache.geronimo.kernel.classloader.JarFileClassLoader.access$200(JarFileClassLoader.java:52)
at org.apache.geronimo.kernel.classloader.JarFileClassLoader$6.run(JarFileClassLoader.java:308)
at java.security.AccessController.doPrivileged(Native Method)
at org.apache.geronimo.kernel.classloader.JarFileClassLoader.findClass(JarFileClassLoader.java:260)
at org.apache.geronimo.kernel.config.MultiParentClassLoader.loadOptimizedClass(MultiParentClassLoader.java:441)
at org.apache.geronimo.kernel.config.MultiParentClassLoader.loadClass(MultiParentClassLoader.java:281)
at java.lang.ClassLoader.loadClass(ClassLoader.java:247)
at org.apache.http.impl.client.DefaultHttpClient.createHttpParams(DefaultHttpClient.java:157)
at org.apache.http.impl.client.AbstractHttpClient.getParams(AbstractHttpClient.java:448)
at org.apache.http.impl.client.AbstractHttpClient.createClientConnectionManager(AbstractHttpClient.java:309)
at org.apache.http.impl.client.AbstractHttpClient.getConnectionManager(AbstractHttpClient.java:466)
at org.apache.http.impl.client.AbstractHttpClient.createHttpContext(AbstractHttpClient.java:286)
at org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:851)
at org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:805)
at org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:784)
at com.test.User.addUser(User.java:18)
... 34 more
It throws the "InvocationTargetException". What may be the problem? Can you give your suggestions?
The problem is right there in the stacktrace:
Caused by: java.lang.VerifyError: Cannot inherit from final class
and if you look closer at the lines below, you can see an indication of where it goes wrong (hint: DefaultHttpClient.createHttpParams(DefaultHttpClient.java:157))
To cut to the chase: Loose the final modifiers on uri, client, postMethod, response and responseData. They're unnecessary and/or wrongly used anyway.
On a completely other note, you could add final modifiers to the methods formal arguments userEmail and password, but do read up on final first.
Cheers,
Related
I call in tomcat war a rest web service. I do the web service invocation with this:
public UsuarioDTO validarDatosToken(String token, boolean incluirRoles) throws ModeloException, DAOException {
RestTemplate restTemplate = new RestTemplate();
UserRestVO page = restTemplate.getForObject("https://xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"), UserRestVO.class);
if (page != null && page.getStatusResult() != null && page.getStatusResult().getStatusCode().equals("OK") && page.getUser() != null) {
------------
return datos;
} else {
throw new ModeloException(ErroresGeneralesEnum.ERROR_TOKEN_CADUCADO);
}
}
}
public Authentication authenticateReal(Authentication authentication) throws AuthenticationException {
String username = authentication.getName();
String password = (String) authentication.getCredentials();
UsuarioDTO usuario = null;
try {
usuario = usuariosService.validarDatosToken(username, true);
} catch (Exception e) {
e.printStackTrace();
Logger.getLogger(CustomAuthenticationProvider.class.getName()).error(e);
throw new BadCredentialsException("Username not found.");
}
}
The following error is produced when web service is called. I try to do a lot of things but notting works:
I think that the problem is with the certificate but i dont solve it.
¿Do you have any idea?
org.springframework.web.client.ResourceAccessException: I/O error on GET request for "https://xxxxxxxxxxxxxxxxxxxxxxxx":java.security.NoSuchAlgorithmException: Error constructing implementation (algorithm: Default, provider: SunJSSE, class: sun.security.ssl.SSLContextImpl$DefaultSSLContext); nested exception is java.net.SocketException: java.security.NoSuchAlgorithmException: Error constructing implementation (algorithm: Default, provider: SunJSSE, class: sun.security.ssl.SSLContextImpl$DefaultSSLContext)
at org.springframework.web.client.RestTemplate.doExecute(RestTemplate.java:567)
at org.springframework.web.client.RestTemplate.execute(RestTemplate.java:512)
at org.springframework.web.client.RestTemplate.getForObject(RestTemplate.java:243)
at custom.service.usuarios.impl.UsuariosServiceImpl.validarDatosToken(UsuariosServiceImpl.java:69)
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.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:317)
at org.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint(ReflectiveMethodInvocation.java:190)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:157)
at org.springframework.transaction.interceptor.TransactionInterceptor$1.proceedWithInvocation(TransactionInterceptor.java:98)
at org.springframework.transaction.interceptor.TransactionAspectSupport.invokeWithinTransaction(TransactionAspectSupport.java:262)
at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:95)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179)
at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:207)
at com.sun.proxy.$Proxy33.validarDatosToken(Unknown Source)
at custom.view.filter.CustomAuthenticationProvider.authenticateReal(CustomAuthenticationProvider.java:48)
at custom.view.filter.CustomAuthenticationProvider.authenticate(CustomAuthenticationProvider.java:37)
at org.springframework.security.authentication.ProviderManager.authenticate(ProviderManager.java:156)
at custom.view.filter.UsernamePasswordAuthenticationFilter.attemptAuthentication(UsernamePasswordAuthenticationFilter.java:103)
at org.springframework.security.web.authentication.AbstractAuthenticationProcessingFilter.doFilter(AbstractAuthenticationProcessingFilter.java:211)
at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342)
at org.springframework.security.web.authentication.logout.LogoutFilter.doFilter(LogoutFilter.java:110)
at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342)
at org.springframework.security.web.context.request.async.WebAsyncManagerIntegrationFilter.doFilterInternal(WebAsyncManagerIntegrationFilter.java:50)
at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)
at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342)
at org.springframework.security.web.context.SecurityContextPersistenceFilter.doFilter(SecurityContextPersistenceFilter.java:87)
at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:342)
at org.springframework.security.web.FilterChainProxy.doFilterInternal(FilterChainProxy.java:192)
at org.springframework.security.web.FilterChainProxy.doFilter(FilterChainProxy.java:160)
at org.springframework.web.filter.DelegatingFilterProxy.invokeDelegate(DelegatingFilterProxy.java:344)
at org.springframework.web.filter.DelegatingFilterProxy.doFilter(DelegatingFilterProxy.java:261)
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:225)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:123)
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:927)
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:1002)
at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:579)
at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:312)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
at java.lang.Thread.run(Thread.java:745)
Caused by: java.net.SocketException: java.security.NoSuchAlgorithmException: Error constructing implementation (algorithm: Default, provider: SunJSSE, class: sun.security.ssl.SSLContextImpl$DefaultSSLContext)
at javax.net.ssl.DefaultSSLSocketFactory.throwException(SSLSocketFactory.java:198)
at javax.net.ssl.DefaultSSLSocketFactory.createSocket(SSLSocketFactory.java:205)
at sun.net.www.protocol.https.HttpsClient.createSocket(HttpsClient.java:409)
at sun.net.NetworkClient.doConnect(NetworkClient.java:162)
at sun.net.www.http.HttpClient.openServer(HttpClient.java:432)
at sun.net.www.http.HttpClient.openServer(HttpClient.java:527)
at sun.net.www.protocol.https.HttpsClient.(HttpsClient.java:275)
at sun.net.www.protocol.https.HttpsClient.New(HttpsClient.java:371)
at sun.net.www.protocol.https.AbstractDelegateHttpsURLConnection.getNewHttpClient(AbstractDelegateHttpsURLConnection.java:191)
at sun.net.www.protocol.http.HttpURLConnection.plainConnect(HttpURLConnection.java:932)
at sun.net.www.protocol.https.AbstractDelegateHttpsURLConnection.connect(AbstractDelegateHttpsURLConnection.java:177)
at sun.net.www.protocol.https.HttpsURLConnectionImpl.connect(HttpsURLConnectionImpl.java:153)
at org.springframework.http.client.SimpleBufferingClientHttpRequest.executeInternal(SimpleBufferingClientHttpRequest.java:75)
at org.springframework.http.client.AbstractBufferingClientHttpRequest.executeInternal(AbstractBufferingClientHttpRequest.java:48)
at org.springframework.http.client.AbstractClientHttpRequest.execute(AbstractClientHttpRequest.java:53)
at org.springframework.web.client.RestTemplate.doExecute(RestTemplate.java:551)
Caused by: java.io.IOException: Invalid keystore format
at sun.security.provider.JavaKeyStore.engineLoad(JavaKeyStore.java:650)
at sun.security.provider.JavaKeyStore$JKS.engineLoad(JavaKeyStore.java:55)
at java.security.KeyStore.load(KeyStore.java:1214)
at sun.security.ssl.TrustManagerFactoryImpl.getCacertsKeyStore(TrustManagerFactoryImpl.java:221)
at sun.security.ssl.SSLContextImpl$DefaultSSLContext.getDefaultTrustManager(SSLContextImpl.java:528)
at sun.security.ssl.SSLContextImpl$DefaultSSLContext.(SSLContextImpl.java:495)
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:57)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
at java.lang.reflect.Constructor.newInstance(Constructor.java:526)
at java.security.Provider$Service.newInstance(Provider.java:1240)
... 64 more
From your code i dont see any specific SSL configuration for your RestTemplate. Since i dont know which version of Spring (and related HTTPClient), i suggest try starting with the following code and see what happens:
public void tryme() throws ClientProtocolException, IOException {
String urlOverHttps = "https:xxxxxxx";
CloseableHttpClient httpClient =
HttpClients.custom()
.setSSLHostnameVerifier(new NoopHostnameVerifier())
.build();
HttpComponentsClientHttpRequestFactory reqFactory =
new HttpComponentsClientHttpRequestFactory();
reqFactory.setHttpClient(httpClient);
ResponseEntity<String> response =
new RestTemplate(reqFactory).exchange(
urlOverHttps, HttpMethod.GET, null, String.class);
String responseCode = response.getStatusCode();
}
This should in theory bypass certs check. It requires HTTPClient 4.4. As i said, you dont expose many details of your current configuration so i can really only wild guess here.
I found the error
Somebody change the etc/init.d/tomcat7 to include two lines with a invalid cert store. Removing it, it's work! thanks to all
-Djavax.net.ssl.keyStore=mySrvKeystore -Djavax.net.ssl.keyStorePassword=123456
I'm currently working on a xCP 2.0 project with Documentum 7.0 and I'm trying to run a Java Service inside a workflow. The Java Service works alright when the function I use does no more than return a "some_string" String. But as soon as I try the actual thing and use documentum specific Objects like:
IDfSession mySession = getSession();
I get these exceptions right here:
java.lang.RuntimeException: Could not invoke the method 'test' from
interface 'class com.gemp1.Test' from BOF module 'gemp1_xCPJava' in
Process Template: 'Peticion de Nuevo Producto v2' - Activity: 'Execute
Java Service'. Workitem: '4a015abd80004959' Workflow: 'Peticion de
Nuevo Producto v2 2014-12-18' - '4d015abd8000411e' Activity: 'Execute
Java Service' - '4c015abd8002e358' Process: 'Peticion de Nuevo
Producto v2' - '4b015abd8002c56c' java.lang.Exception:
java.lang.RuntimeException: Could not invoke the method 'test' from
interface 'class com.gemp1.Test' from BOF module 'gemp1_xCPJava' at
com.documentum.bps.outbound.AbstractService.execute(AbstractService.java:98)
at
com.documentum.bpm.services.BPSIntegrationFramework.executeService(BPSIntegrationFramework.java:260)
at
com.documentum.bpm.services.BPSIntegrationFramework.executeMethod(BPSIntegrationFramework.java:92)
at
com.documentum.bpm.services.BPSIntegrationMethod.executeMethod(BPSIntegrationMethod.java:26)
at
com.documentum.bpm.rtutil.GenericWorkflowMethod.execute(GenericWorkflowMethod.java:129)
at
com.documentum.bpm.rtutil.GenericWorkflowMethod.execute(GenericWorkflowMethod.java:355)
at
com.documentum.bpm.rtutil.GenericWorkflowMethod.execute(GenericWorkflowMethod.java:70)
at com.documentum.mthdservlet.DfMethodRunner.runIt(Unknown Source)
at com.documentum.mthdservlet.AMethodRunner.runAndReturnStatus(Unknown
Source) at com.documentum.mthdservlet.DoMethod.invokeMethod(Unknown
Source) at com.documentum.mthdservlet.DoMethod.doPost(Unknown
Source) at
javax.servlet.http.HttpServlet.service(HttpServlet.java:637) at
javax.servlet.http.HttpServlet.service(HttpServlet.java:717) 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:235)
at
org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
at
org.jboss.web.tomcat.security.SecurityAssociationValve.invoke(SecurityAssociationValve.java:190)
at
org.jboss.web.tomcat.security.JaccContextValve.invoke(JaccContextValve.java:92)
at
org.jboss.web.tomcat.security.SecurityContextEstablishmentValve.process(SecurityContextEstablishmentValve.java:126)
at
org.jboss.web.tomcat.security.SecurityContextEstablishmentValve.invoke(SecurityContextEstablishmentValve.java:70)
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:158)
at
org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
at
org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:330)
at
org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:829)
at
org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:598)
at
org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:447)
at java.lang.Thread.run(Thread.java:662) Caused by:
java.lang.RuntimeException: Could not invoke the method 'test' from
interface 'class com.gemp1.Test' from BOF module 'gemp1_xCPJava' at
com.documentum.bps.outbound.bof.runtime.BOFClient.invokeMethod(BOFClient.java:121)
at
com.documentum.bps.outbound.bof.runtime.BofModuleService.executeServiceOperation(BofModuleService.java:133)
at
com.documentum.bps.outbound.AbstractService.executeServiceInternal(AbstractService.java:122)
at
com.documentum.bps.outbound.AbstractService.execute(AbstractService.java:79)
... 32 more Caused by: java.lang.reflect.InvocationTargetException
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
com.documentum.bps.outbound.bof.runtime.BOFClient.invokeMethod(BOFClient.java:112)
... 35 more Caused by: java.lang.NullPointerException at
com.documentum.fc.client.DfSingleDocbaseModule.getSession(DfSingleDocbaseModule.java:58)
at com.gemp1.Test.test(Test.java:11) ... 40 more
My Java class:
package com.gemp1;
import com.documentum.fc.client.*;
import com.documentum.fc.common.DfException;
public class Test extends DfSingleDocbaseModule {
public String test() {
String result = "Hello12345";
return result;
}
public String[] getUsers() throws DfException {
String docbaseUsers[] = new String[200];
IDfCollection coll = null;
IDfSession mySession = getSession();
String myQuery = "select user_name from dm_user";
IDfQuery myDFQuery = new DfQuery(myQuery);
coll = myDFQuery.execute(mySession, IDfQuery.DF_QUERY);
int i=0;
while (coll.next()) {
docbaseUsers[i] = coll.getString("user_name");
i++;
}
return docbaseUsers;
}
}
And finally my javamodule file:
<?xml version="1.0" encoding="UTF-8"?>
<nsJavaModule:JavaModule xmlns:nsJavaModule="http://xcp.emc.com/javamodule" urn="urn:gemp1:com.emc.xcp.artifact.javamodule.category:Artifacts/Java Modules/xCPJava.javamodule" categoryId="com.emc.xcp.artifact.javamodule.category" name="xCPJava" label="xCPJava" implementationClass="com.gemp1.Test">
<implementationJars contentPath="content/modules/xCPJava.jar"/>
<implementationJars contentPath="content/modules/dfc.jar"/>
</nsJavaModule:JavaModule>
Am I missing something?
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.
I am using Google Places API and trying to send a POST request to add a new place. But I keep getting a NullPointerException on the request.execute() part.
// Create POST body.
GenericData data = new GenericData();
GenericData coordinates = new GenericData();
coordinates.put("lat", latitude);
coordinates.put("lng", longitude);
data.put("location", coordinates);
data.put("accuracy", 50);
data.put("name", name);
JsonHttpContent content = new JsonHttpContent();
content.data = data;
// Send POST request.
HttpRequestFactory httpRequestFactory = LocationUtil.createRequestFactory(transport);
HttpRequest request = httpRequestFactory.buildPostRequest(new GenericUrl(GooglePlacesConsts.PLACES_REPORT_ADD_URL), content);
request.url.put("sensor", "false");
request.url.put("key", GooglePlacesConsts.API_KEY);
HttpResponse response = request.execute();
The code for createRequestFactory() is (this is from Davy's Tech Blog):
public static HttpRequestFactory createRequestFactory(final HttpTransport transport) {
return transport.createRequestFactory(new HttpRequestInitializer() {
public void initialize(HttpRequest request) {
GoogleHeaders headers = new GoogleHeaders();
headers.setApplicationName("App Name");
request.headers = headers;
JsonHttpParser parser = new JsonHttpParser();
parser.jsonFactory = new JacksonFactory();
request.addParser(parser);
}
});
}
Is the code wrong? I kinda borrowed lines of codes from different sources, because I...don't know how to correctly send a POST request in Java. Mainly, I followed the tutorial from Davy's Tech Blog, but also tried to follow this post, because the previous link provided examples only for sending GET requests, and I need to send a POST request.
By the way, this is the stack trace:
javax.faces.FacesException: #{locationBean.actionAdd}: java.lang.NullPointerException
at com.sun.faces.application.ActionListenerImpl.processAction(ActionListenerImpl.java:118)
at javax.faces.component.UICommand.broadcast(UICommand.java:315)
at javax.faces.component.UIViewRoot.broadcastEvents(UIViewRoot.java:794)
at javax.faces.component.UIViewRoot.processApplication(UIViewRoot.java:1259)
at com.sun.faces.lifecycle.InvokeApplicationPhase.execute(InvokeApplicationPhase.java:81)
at com.sun.faces.lifecycle.Phase.doPhase(Phase.java:101)
at com.sun.faces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:118)
at javax.faces.webapp.FacesServlet.service(FacesServlet.java:593)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at org.apache.myfaces.webapp.filter.ExtensionsFilter.doFilter(ExtensionsFilter.java:349)
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:233)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:298)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:859)
at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:588)
at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:489)
at java.lang.Thread.run(Unknown Source)
Caused by: javax.faces.el.EvaluationException: java.lang.NullPointerException
at javax.faces.component.MethodBindingMethodExpressionAdapter.invoke(MethodBindingMethodExpressionAdapter.java:102)
at com.sun.faces.application.ActionListenerImpl.processAction(ActionListenerImpl.java:102)
... 22 more
Caused by: java.lang.NullPointerException
at com.google.api.client.http.json.JsonHttpContent.writeTo(JsonHttpContent.java:75)
at com.google.api.client.http.apache.ContentEntity.writeTo(ContentEntity.java:56)
at org.apache.http.entity.HttpEntityWrapper.writeTo(HttpEntityWrapper.java:101)
at org.apache.http.impl.client.EntityEnclosingRequestWrapper$EntityWrapper.writeTo(EntityEnclosingRequestWrapper.java:107)
at org.apache.http.impl.entity.EntitySerializer.serialize(EntitySerializer.java:127)
at org.apache.http.impl.AbstractHttpClientConnection.sendRequestEntity(AbstractHttpClientConnection.java:253)
at org.apache.http.impl.conn.AbstractClientConnAdapter.sendRequestEntity(AbstractClientConnAdapter.java:218)
at org.apache.http.protocol.HttpRequestExecutor.doSendRequest(HttpRequestExecutor.java:249)
at org.apache.http.protocol.HttpRequestExecutor.execute(HttpRequestExecutor.java:124)
at org.apache.http.impl.client.DefaultRequestDirector.execute(DefaultRequestDirector.java:483)
at org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:641)
at org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:576)
at org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:554)
at com.google.api.client.http.apache.ApacheHttpRequest.execute(ApacheHttpRequest.java:58)
at com.google.api.client.http.HttpRequest.execute(HttpRequest.java:361)
at model.location.LocationBean.actionAdd(LocationBean.java:57)
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.apache.el.parser.AstValue.invoke(AstValue.java:191)
at org.apache.el.MethodExpressionImpl.invoke(MethodExpressionImpl.java:276)
at com.sun.faces.facelets.el.TagMethodExpression.invoke(TagMethodExpression.java:105)
at javax.faces.component.MethodBindingMethodExpressionAdapter.invoke(MethodBindingMethodExpressionAdapter.java:88)
... 23 more
Thank you!
I struggled to find a version of that class that had a line number valid for your exception, but I found 1.4.1-beta.
public void writeTo(OutputStream out) throws IOException {
JsonGenerator generator = jsonFactory.createJsonGenerator(out, JsonEncoding.UTF8);
generator.serialize(data);
generator.flush();
}
Line 45 is the first line of the method. So check that jsonFactory is not null.
I have asked this question in Hibernate forum for a week without an anwser - https://forum.hibernate.org/viewtopic.php?f=1&t=1011634. I am really stuck here and hopefully can get help here. I got NullPointerException from org.hibernate.engine.StatefulPersistenceContext.
My hibernate dependency is as follows:
org.hibernate
hibernate-entitymanager
3.5.6-Final
The exception stack is below:
2011-07-04 07:06:38,691 DEBUG [http-8080-2] mobi.esca.mobile.remoting.HttpInvokerServiceExporter (HttpInvokerServiceExporter.java:168) - java.lang.NullPointerException
java.lang.NullPointerException
at org.hibernate.engine.StatefulPersistenceContext.replaceDelayedEntityIdentityInsertKeys(StatefulPersistenceContext.java:1401)
at org.hibernate.action.EntityIdentityInsertAction.postInsert(EntityIdentityInsertAction.java:117)
at org.hibernate.action.EntityIdentityInsertAction.execute(EntityIdentityInsertAction.java:89)
at org.hibernate.engine.ActionQueue.execute(ActionQueue.java:267)
at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:259)
at org.hibernate.engine.ActionQueue.executeInserts(ActionQueue.java:169)
at org.hibernate.event.def.AbstractSaveEventListener.performSaveOrReplicate(AbstractSaveEventListener.java:287)
at org.hibernate.event.def.AbstractSaveEventListener.performSave(AbstractSaveEventListener.java:204)
at org.hibernate.event.def.AbstractSaveEventListener.saveWithGeneratedId(AbstractSaveEventListener.java:130)
at org.hibernate.ejb.event.EJB3PersistEventListener.saveWithGeneratedId(EJB3PersistEventListener.java:69)
at org.hibernate.event.def.DefaultPersistEventListener.entityIsTransient(DefaultPersistEventListener.java:179)
at org.hibernate.event.def.DefaultPersistEventListener.onPersist(DefaultPersistEventListener.java:135)
at org.hibernate.event.def.DefaultPersistEventListener.onPersist(DefaultPersistEventListener.java:61)
at org.hibernate.impl.SessionImpl.firePersist(SessionImpl.java:800)
at org.hibernate.impl.SessionImpl.persist(SessionImpl.java:774)
at org.hibernate.impl.SessionImpl.persist(SessionImpl.java:778)
at org.hibernate.ejb.AbstractEntityManagerImpl.persist(AbstractEntityManagerImpl.java:668)
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.orm.jpa.ExtendedEntityManagerCreator$ExtendedEntityManagerInvocationHandler.invoke(ExtendedEntityManagerCreator.java:365)
at $Proxy138.persist(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.orm.jpa.SharedEntityManagerCreator$SharedEntityManagerInvocationHandler.invoke(SharedEntityManagerCreator.java:240)
at $Proxy59.persist(Unknown Source)
at org.springframework.orm.jpa.JpaTemplate$5.doInJpa(JpaTemplate.java:264)
at org.springframework.orm.jpa.JpaTemplate.execute(JpaTemplate.java:183)
at org.springframework.orm.jpa.JpaTemplate.persist(JpaTemplate.java:262)
at mobi.esca.persistence.GenericJPARepository.persist(GenericJPARepository.java:153)
at mobi.esca.persistence.GenericJPARepository.persistAll(GenericJPARepository.java:161)
at mobi.esca.mars.application.UsageManager.logUsageStats(UsageManager.java:43)
at mobi.esca.mars.interfaces.mobile.EndUserController.reportStats(EndUserController.java:259)
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:309)
at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:196)
at $Proxy137.reportStats(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 mobi.esca.mobile.remoting.RemoteInvocationAdaptor.invoke(RemoteInvocationAdaptor.java:89)
at mobi.esca.mobile.remoting.RemoteInvocationAdaptor.proceed(RemoteInvocationAdaptor.java:54)
at mobi.esca.mobile.remoting.FilterChain.doFilter(FilterChain.java:59)
at mobi.esca.mobile.remoting.MethodInvocationRateFromUserProtection.doFilter(MethodInvocationRateFromUserProtection.java:56)
at mobi.esca.mobile.remoting.FilterChain.doFilter(FilterChain.java:56)
at mobi.esca.mobile.remoting.MethodInvocationRateFromIpProtection.doFilter(MethodInvocationRateFromIpProtection.java:57)
at mobi.esca.mobile.remoting.FilterChain.doFilter(FilterChain.java:56)
at mobi.esca.mars.interfaces.mobile.ClientVersionChecker.doFilter(ClientVersionChecker.java:41)
at mobi.esca.mobile.remoting.FilterChain.doFilter(FilterChain.java:56)
at mobi.esca.mobile.remoting.AuthenticationFilter.doFilter(AuthenticationFilter.java:37)
at mobi.esca.mobile.remoting.FilterChain.doFilter(FilterChain.java:56)
at mobi.esca.mobile.remoting.HttpInvokerServiceExporter.invokeAndCreateResult(HttpInvokerServiceExporter.java:201)
at mobi.esca.mobile.remoting.HttpInvokerServiceExporter.handleRequestInternal(HttpInvokerServiceExporter.java:128)
at mobi.esca.mobile.remoting.HttpInvokerServiceExporter.handleRequest(HttpInvokerServiceExporter.java:102)
at org.springframework.web.servlet.mvc.HttpRequestHandlerAdapter.handle(HttpRequestHandlerAdapter.java:49)
at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:790)
at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:719)
at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:644)
at org.springframework.web.servlet.FrameworkServlet.doPost(FrameworkServlet.java:560)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:637)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:88)
at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:76)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at org.springframework.orm.jpa.support.OpenEntityManagerInViewFilter.doFilterInternal(OpenEntityManagerInViewFilter.java:113)
at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:76)
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:219)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:298)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:852)
at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:588)
at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:489)
I am looking at the line 1401 of StatefulPersistenceContext.java file:
1396 public void replaceDelayedEntityIdentityInsertKeys(EntityKey oldKey, Serializable generatedId) {
1397 Object entity = entitiesByKey.remove( oldKey );
1398 EntityEntry oldEntry = ( EntityEntry ) entityEntries.remove( entity );
1399 parentsByChild.clear();
1400
1401 EntityKey newKey = new EntityKey( generatedId, oldEntry.getPersister(), getSession().getEntityMode() );
1402 addEntity( newKey, entity );
so the possible null object here could be oldEntry, right? Could anyone tell me when oldEntry can become null? What can i do to fix the problem?
Your help will be highly appreciated.
Many thanks,
Cheng Wei
Hi Moe,
Thanks for your reply. The exception are happening randomly in various methods in our system now, and i can not recreate it by unit test. I will give a simplest code from a method.
#Controller
public class EndUserController implements EndUserService, InvocationContextRequired
{
#Override
public void reportStats(UsageStatsDTO usageStatsDTO) throws ClientVersionOutOfDateException
{
log.debug("enter UsageReportController.reportStats()");
UsageStats usageStats = usageStatsDTO.asUsageStats(getEndUser());
usageManager.logUsageStats(usageStats);
if(usageStats.hasAppStartEvent())
{
endUserManager.updateClientVersion(getEndUser(), getClientVersion());
}
log.debug("exit UsageReportController.reportStats()");
}
......
}
#Service
public class UsageManager
{
#Autowired
private CallEventRepository callEventRepository;
#Autowired
private AppStartEventRepository appStartEventRepository;
#Autowired
private InviteEventRepository inviteEventRepository;
#Transactional
public void logUsageStats(UsageStats usageStats)
{
if (usageStats.hasCallEvent())
{
callEventRepository.persistAll(usageStats.getCallEvents());
}
if (usageStats.hasAppStartEvent())
{
appStartEventRepository.persistAll(usageStats.getAppStartEvents());
}
if (usageStats.hasInviteEvent())
{
inviteEventRepository.persistAll(usageStats.getInviteEvents());
}
}
......
}
public class GenericJPARepository<T, ID extends Serializable>
implements GenericRepository<T, ID>
{
#Override
public T persist(T entity)
{
getJpaTemplate().persist(entity);
return entity;
}
#Override
public void persistAll(Collection<T> entities)
{
for(T entity : entities)
{
persist(entity);
}
}
......
}
And all RepositoryImpl classes are the subclasses(CallEventRepository,AppStartEventRepository,InviteEventRepository) of GenericJPARepository.
Many thanks,
Cheng Wei
Can problem be caused by i detach an entity? endUserRepository.detach(detatchedEndUser); But UsageStats, the object to be persisted, does not reference to detatchedEndUser.
Thanks Moe and Maurice, Appreciate your help. I finally find the problem. the following code caused the problem:
EndUser toBePersistedEndUser = endUserRepository.persist(new EndUser(remoteEndUser));
endUserRepository.detach(toBePersistedEndUser );
return toBePersistedEndUser;
Also, i think i reveal a bug for hibernate here.
Problem solved, Many thanks,
Cheng Wei
Well, either oldEntry is null, or getSession() returns null.
Obviously, oldEntry will be null if the entityEntries doesn't contain the entry removed from entitiesByKey. It could also happen if the equals() method for EntityEntry is incorrectly implemented.