Hola un gust en saludar- , si us plau necessito que m’ajudin amb el següent problema, resulta que tinc una aplicació en Java que requereix consumir un servei de seguretat d’una URI especifica, aquesta funcionalitat la comprimo en un JAR generat des d’un arxiu build.xml, per després poder crear un objecte que em permeti fer ús dels seus mètodes.
Faig servir Eclipse com IDE i la versió de l’compilador requerida per a aquest projecte és JDK 1.6_29, i a el parer es genera el JAR bé, fins i tot l’importo com llibreria al Java Builpath i la classe on es troba el objecte que instància el mètode d’aquest servei em treu l’error de que la importació de la llibreria no es pot realitzar.
el punt és que a l’hora de desplegar les classes al servidor d’aplicacions que en el meu cas és Oracle Weblogic 11g, el log em llança el següent:
2020.01.17 09:08:29.902 - ERROR - srvtstrma1.tmve.local - Thread - com.tmv.lcl.runtime.dao.AbstractDAO - execute(90) - 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.tmv.lcl.runtime.dao.AbstractDAO.execute(AbstractDAO.java:85) at com.tmv.lcl.runtime.executor.tmve.utilities.AuthenticateUserBSExecutor.executeBusinessRule(AuthenticateUserBSExecutor.java:77) at com.tmv.lcl.runtime.controller.DefaultController.execute(DefaultController.java:110) at com.tmv.lcl.runtime.controller.tmve.DefaultController.execute(DefaultController.java:29) at com.tmv.lcl.services.ServiceBrokerImpl.execute(Unknown Source) at sun.reflect.GeneratedMethodAccessor79.invoke(Unknown Source) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) at java.lang.reflect.Method.invoke(Method.java:597) at weblogic.wsee.jaxws.WLSInstanceResolver$WLSInvoker.invoke(WLSInstanceResolver.java:92) at weblogic.wsee.jaxws.WLSInstanceResolver$WLSInvoker.invoke(WLSInstanceResolver.java:74) at com.sun.xml.ws.server.InvokerTube$2.invoke(InvokerTube.java:151) at com.sun.xml.ws.server.sei.EndpointMethodHandlerImpl.invoke(EndpointMethodHandlerImpl.java:268) at com.sun.xml.ws.server.sei.SEIInvokerTube.processRequest(SEIInvokerTube.java:100) at com.sun.xml.ws.api.pipe.Fiber.__doRun(Fiber.java:866) at com.sun.xml.ws.api.pipe.Fiber._doRun(Fiber.java:815) at com.sun.xml.ws.api.pipe.Fiber.doRun(Fiber.java:778) at com.sun.xml.ws.api.pipe.Fiber.runSync(Fiber.java:680) at com.sun.xml.ws.server.WSEndpointImpl$2.process(WSEndpointImpl.java:403) at com.sun.xml.ws.transport.http.HttpAdapter$HttpToolkit.handle(HttpAdapter.java:532) at com.sun.xml.ws.transport.http.HttpAdapter.handle(HttpAdapter.java:253) at com.sun.xml.ws.transport.http.servlet.ServletAdapter.handle(ServletAdapter.java:140) at weblogic.wsee.jaxws.WLSServletAdapter.handle(WLSServletAdapter.java:171) at weblogic.wsee.jaxws.HttpServletAdapter$AuthorizedInvoke.run(HttpServletAdapter.java:708) at weblogic.security.acl.internal.AuthenticatedSubject.doAs(AuthenticatedSubject.java:363) at weblogic.security.service.SecurityManager.runAs(SecurityManager.java:146) at weblogic.wsee.util.ServerSecurityHelper.authenticatedInvoke(ServerSecurityHelper.java:103) at weblogic.wsee.jaxws.HttpServletAdapter$3.run(HttpServletAdapter.java:311) at weblogic.wsee.jaxws.HttpServletAdapter.post(HttpServletAdapter.java:336) at weblogic.wsee.jaxws.JAXWSServlet.doRequest(JAXWSServlet.java:95) at weblogic.servlet.http.AbstractAsyncServlet.service(AbstractAsyncServlet.java:99) at javax.servlet.http.HttpServlet.service(HttpServlet.java:820) at weblogic.servlet.internal.StubSecurityHelper$ServletServiceAction.run(StubSecurityHelper.java:227) at weblogic.servlet.internal.StubSecurityHelper.invokeServlet(StubSecurityHelper.java:125) at weblogic.servlet.internal.ServletStubImpl.execute(ServletStubImpl.java:300) at weblogic.servlet.internal.ServletStubImpl.execute(ServletStubImpl.java:183) at weblogic.servlet.internal.WebAppServletContext$ServletInvocationAction.wrapRun(WebAppServletContext.java:3717) at weblogic.servlet.internal.WebAppServletContext$ServletInvocationAction.run(WebAppServletContext.java:3681) at weblogic.security.acl.internal.AuthenticatedSubject.doAs(AuthenticatedSubject.java:321) at weblogic.security.service.SecurityManager.runAs(SecurityManager.java:120) at weblogic.servlet.internal.WebAppServletContext.securedExecute(WebAppServletContext.java:2277) at weblogic.servlet.internal.WebAppServletContext.execute(WebAppServletContext.java:2183) at weblogic.servlet.internal.ServletRequestImpl.run(ServletRequestImpl.java:1454) at weblogic.work.ExecuteThread.execute(ExecuteThread.java:209) at weblogic.work.ExecuteThread.run(ExecuteThread.java:178)Caused by: java.lang.NoClassDefFoundError: org/tempuri/SeguridadWebService_Impl at com.tmv.lcl.runtime.dao.core.TConectaWSDAO.encryptPassword(TConectaWSDAO.java:25) ... 48 more
La classe on Instancio el mètode de el servei que consum és de tipus DAO
package com.tmv.lcl.runtime.dao.core;import com.tmv.commons.logging.Logger;import com.tmv.commons.tracing.Tracer;import com.tmv.lcl.commons.engine.LCLException;import com.tmv.lcl.runtime.constants.tmve.Errors;import com.tmv.lcl.runtime.dao.WebServiceDAO;import org.tempuri.*; //LA LIBRERIA QUE NECESITOimport java.rmi.RemoteException;import static com.tmv.lcl.runtime.executor.tmve.utilities.AuthenticateUserBSExecutor.urlSeguridad;public class TConectaWSDAO extends WebServiceDAO { private String urlWebServiceAddress = null; public TConectaWSDAO() { super(WSTYPE_JAXRPC); urlWebServiceAddress = urlSeguridad; } public String encryptPassword (String pass) throws LCLException{ Tracer tracer = Tracer.getTracer(); Logger logger = Logger.getLogger(); tracer.begin(); logger.info("Iniciando metodo de encriptacion: {0}",pass); logger.debug("urlWebServiceAddress: {0}", urlWebServiceAddress); try { logger.debug("Antes de crear objeto de acceso a SeguridadWebService"); SeguridadWebService encrypt = new SeguridadWebService_Impl(urlWebServiceAddress); //AQUI ESTA FALLANDO logger.debug("Despues de crear objeto de acceso a SeguridadWebService: ", encrypt); String operationResult = encrypt.getBasicHttpBinding_ISeguridadWebService().encriptar(pass,"TCONECTA"); logger.debug("Objeto operationResult: ", operationResult); return operationResult; } catch (RemoteException re) { logger.fatal("Error de ejecuci\u00F3n del servicio de encriptacion: {0}", re); throw new LCLException(Errors.ERROR_CONSUMO_SERVICIO.getText(),Errors.ERROR_CONSUMO_SERVICIO.getId()); } catch (Exception e) { e.printStackTrace(); throw new LCLException(e.getMessage()); } finally { tracer.end(); } }}
interfície SeguridadWebService
package org.tempuri;/** * Generated class, do not edit. * * This service interface was generated by weblogic * webservice stub gen on Thu Jan 16 10:30:25 BOT 2020 */public interface SeguridadWebService extends javax.xml.rpc.Service { weblogic.wsee.context.WebServiceContext context(); weblogic.wsee.context.WebServiceContext joinContext() throws weblogic.wsee.context.ContextNotFoundException; //*********************************** // Port Name: BasicHttpBinding_ISeguridadWebService // Port Type: ISeguridadWebService //*********************************** /** * returns BasicHttpBinding_ISeguridadWebService port in this service */ org.tempuri.ISeguridadWebService getBasicHttpBinding_ISeguridadWebService() throws javax.xml.rpc.ServiceException; /** * @deprecated Use getBasicHttpBinding_ISeguridadWebService(byte username, byte password); */ org.tempuri.ISeguridadWebService getBasicHttpBinding_ISeguridadWebService(String username, String password) throws javax.xml.rpc.ServiceException; org.tempuri.ISeguridadWebService getBasicHttpBinding_ISeguridadWebService(byte username, byte password) throws javax.xml.rpc.ServiceException; }
Classe SeguridadWebService_Impl que implementa interfície SeguridadWebService
package org.tempuri;/** * Generated class, do not edit. * * This service class was generated by weblogic * webservice stub gen on Thu Jan 16 10:30:25 BOT 2020 */public class SeguridadWebService_Impl extends weblogic.wsee.jaxrpc.ServiceImpl implements org.tempuri.SeguridadWebService { public SeguridadWebService_Impl() throws javax.xml.rpc.ServiceException { this("org/tempuri/SeguridadWebService_saved_wsdl.wsdl", null); } public SeguridadWebService_Impl(String wsdlurl) throws javax.xml.rpc.ServiceException { this(wsdlurl, null); } public SeguridadWebService_Impl(String wsdlurl, weblogic.wsee.connection.transport.TransportInfo transportInfo) throws javax.xml.rpc.ServiceException { super(wsdlurl, new javax.xml.namespace.QName("http://tempuri.org/", "SeguridadWebService"), "org/tempuri/SeguridadWebService_internaldd.xml", transportInfo); } //*********************************** // Port Name: BasicHttpBinding_ISeguridadWebService // Port Type: ISeguridadWebService //*********************************** org.tempuri.ISeguridadWebService mvar_BasicHttpBinding_ISeguridadWebService; /** * returns BasicHttpBinding_ISeguridadWebService port in this service */ public org.tempuri.ISeguridadWebService getBasicHttpBinding_ISeguridadWebService() throws javax.xml.rpc.ServiceException { if (mvar_BasicHttpBinding_ISeguridadWebService == null) { mvar_BasicHttpBinding_ISeguridadWebService = new org.tempuri.ISeguridadWebService_Stub(_getPort("BasicHttpBinding_ISeguridadWebService"), this); } if (transportInfo != null && transportInfo instanceof weblogic.wsee.connection.transport.http.HttpTransportInfo) { ((javax.xml.rpc.Stub)mvar_BasicHttpBinding_ISeguridadWebService)._setProperty( "weblogic.wsee.connection.transportinfo", (weblogic.wsee.connection.transport.http.HttpTransportInfo)transportInfo); } return mvar_BasicHttpBinding_ISeguridadWebService; } /** * @deprecated Use getBasicHttpBinding_ISeguridadWebService(byte username, byte password) */ public org.tempuri.ISeguridadWebService getBasicHttpBinding_ISeguridadWebService(String username, String password) throws javax.xml.rpc.ServiceException { if (username != null & password != null) { weblogic.wsee.connection.transport.http.HttpTransportInfo httpInfo = new weblogic.wsee.connection.transport.http.HttpTransportInfo(); httpInfo.setUsername(username.getBytes()); httpInfo.setPassword(password.getBytes()); transportInfo = httpInfo; } return getBasicHttpBinding_ISeguridadWebService(); } public org.tempuri.ISeguridadWebService getBasicHttpBinding_ISeguridadWebService(byte username, byte password) throws javax.xml.rpc.ServiceException { if (username != null & password != null) { weblogic.wsee.connection.transport.http.HttpTransportInfo httpInfo = new weblogic.wsee.connection.transport.http.HttpTransportInfo(); httpInfo.setUsername(username); httpInfo.setPassword(password); transportInfo = httpInfo; } return getBasicHttpBinding_ISeguridadWebService(); }}
per últim deixo les parts que interessen de l’arxiu build.xml per a la generació d’aquest JAR:
<?xml version="1.0" encoding="UTF-8"?><project name="LCL-TST" default="build-service"> <property name="src.dir" value="src" /> <property name="lib.dir" value="lib" /> <property name="build.dir" value="classes" /> <property name="rtc.dir" value="rtc" /> <property name="deployments.dir" value="deployments" /> <property name="ORA_HOME" value="D:/Oracle/Middleware" /> <property name="WL_HOME" value="${ORA_HOME}/wlserver_10.3" /> <property name="JAVA_HOME" value="D:/Oracle/Middleware/jdk1.6.0_29" /> <property name="javac.tools" value="${JAVA_HOME}/lib/tools.jar" /> <property name="rtc.domain.dir" value="${domain.dir}/rtc" /> <property name="lib.domain.dir" value="${domain.dir}/lib" /> <property name="wsdl.dir" value="wsdl" /> <property name="wsdl.domain.dir" value="${domain.dir}/wsdl" /> <property name="tconecta.url" value="http://10.164.5.200/tconecta.services/web" /> <path> <pathelement location="${WL_HOME}/server/lib/weblogic.jar" /> <pathelement location="${WL_HOME}/server/lib/webservices.jar" /> <pathelement location="${javac.tools}" /> </path> <!-- Servicios TCONECTA --> <taskdef name="clientgen" classname="weblogic.wsee.tools.anttasks.ClientGenTask" classpathref="wl.classpath" /> <target name="external-services-tconecta"> <tstamp> <format property="tmp.time" pattern="hhmmss" unit="hour" /> </tstamp> <mkdir dir="${tmp.dir}" /> <property name="tconecta.package" value="dpi.ws.services.stub" /> <property name="tconecta.lib.jar" value="${lib.dir}/external-services-tconecta.jar" /> <clientgen wsdl ="${tconecta.url}/SeguridadWebService.svc?WSDL" verbose="false" servicename="SeguridadWebService" destdir="${tmp.dir}" classpathref="wl.classpath"/> <javac srcdir="${tmp.dir}" destdir="${tmp.dir}" debug="on" includes="**/*.java" includeantruntime="false"> <classpath refid="wl.classpath" /> </javac> <jar destfile="${lib.dir}/external-services-tconecta.jar"> <fileset dir="${tmp.dir}" includes="**/*" /> </jar> <delete dir="${tmp.dir}" includeemptydirs="yes" /> </target></project>