java.lang.NoSuchFieldError: WADL_JSON in creating jersey rest client - java

I am creating jersey rest client with jackson pojo mapping.
here is code spinet:
ClientConfig clientConfig = new DefaultClientConfig();
clientConfig.getClasses().add(JacksonJsonProvider.class);
clientConfig.getFeatures().put(JSONConfiguration.FEATURE_POJO_MAPPING, Boolean.TRUE);
client = Client.create(clientConfig);
webResource = client.resource("url to exposed rest web service");
This code is throwing following exception at line client = Client.create(clientConfig)
Sep 01, 2014 12:42:04 PM com.sun.jersey.core.spi.component.ProviderFactory __getComponentProvider
SEVERE: The provider class, class com.sun.jersey.json.impl.provider.entity.JSONRootElementProvider$Wadl, could not be instantiated. Processing will continue but the class will not be utilized
java.lang.NoSuchFieldError: WADL_JSON
at com.sun.jersey.json.impl.provider.entity.JSONRootElementProvider$Wadl.<init>(JSONRootElementProvider.java:138)
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 com.sun.jersey.core.spi.component.ComponentConstructor._getInstance(ComponentConstructor.java:161)
at com.sun.jersey.core.spi.component.ComponentConstructor.getInstance(ComponentConstructor.java:141)
at com.sun.jersey.core.spi.component.ProviderFactory.__getComponentProvider(ProviderFactory.java:163)
at com.sun.jersey.core.spi.component.ProviderFactory.getComponentProvider(ProviderFactory.java:134)
at com.sun.jersey.core.spi.component.ProviderServices.getComponent(ProviderServices.java:232)
at com.sun.jersey.core.spi.component.ProviderServices.getProvidersAndServices(ProviderServices.java:149)
at com.sun.jersey.core.spi.factory.MessageBodyFactory.initReaders(MessageBodyFactory.java:153)
at com.sun.jersey.core.spi.factory.MessageBodyFactory.init(MessageBodyFactory.java:145)
at com.sun.jersey.api.client.Client.<init>(Client.java:275)
at com.sun.jersey.api.client.Client.<init>(Client.java:150)
at com.sun.jersey.api.client.Client.create(Client.java:476)
at com.snapdeal.rnrs.client.RClient.<init>(RClient.java:29)
at com.snapdeal.rnrs.client.RestClient.main(RestClient.java:45)
Sep 01, 2014 12:42:04 PM com.sun.jersey.core.spi.component.ProviderFactory __getComponentProvider
SEVERE: The provider class, class com.sun.jersey.json.impl.provider.entity.JSONRootElementProvider$Wadl, could not be instantiated. Processing will continue but the class will not be utilized
java.lang.NoSuchFieldError: WADL_JSON
at com.sun.jersey.json.impl.provider.entity.JSONRootElementProvider$Wadl.<init>(JSONRootElementProvider.java:138)
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 com.sun.jersey.core.spi.component.ComponentConstructor._getInstance(ComponentConstructor.java:161)
at com.sun.jersey.core.spi.component.ComponentConstructor.getInstance(ComponentConstructor.java:141)
at com.sun.jersey.core.spi.component.ProviderFactory.__getComponentProvider(ProviderFactory.java:163)
at com.sun.jersey.core.spi.component.ProviderFactory.getComponentProvider(ProviderFactory.java:134)
at com.sun.jersey.core.spi.component.ProviderServices.getComponent(ProviderServices.java:232)
at com.sun.jersey.core.spi.component.ProviderServices.getProvidersAndServices(ProviderServices.java:149)
at com.sun.jersey.core.spi.factory.MessageBodyFactory.initWriters(MessageBodyFactory.java:171)
at com.sun.jersey.core.spi.factory.MessageBodyFactory.init(MessageBodyFactory.java:146)
at com.sun.jersey.api.client.Client.<init>(Client.java:275)
at com.sun.jersey.api.client.Client.<init>(Client.java:150)
at com.sun.jersey.api.client.Client.create(Client.java:476)
at com.snapdeal.rnrs.client.RClient.<init>(RClient.java:29)
at com.snapdeal.rnrs.client.RestClient.main(RestClient.java:45)
I am using following jars:
jackson-core-asl:1.9.13
jackson-jaxrs:1.9.13
jackson-xc:1.9.13
jersey-client:1.1.5.1
I am fed up searching google and stackoverflow, but could not find any solution. Please suggest some solution if any one faced the same error and solved the problem.

I got the solution of the problem. It was due to jar conflicts.
I change jersey-client:1.1.5.1 to jersey-client:1.18

Related

BindException when trying to run dual projects

Trying to run 2 separate Vertx applications. They both connect to the same database. I am getting the following bind exception.
I am only using http server on one of the projects thus don't think the following even matters. But tried it anyway with no difference. The error seems to stem from the attempt to connect to DB or so I think based on the exception. How can I overcome this to be able to run both projects same time? Please advice. Thanks.
Passing in the following as an environment variable doesn't make a diff as expected:
http.port=8095
Neither does setting port in following way makes a diff.
int port = 8095;
DeploymentOptions options = new DeploymentOptions().setConfig(new JsonObject().put("http.port", port));
vertx.deployVerticle("verticle.MyVerticle", options);
Exception:
Aug 31, 2020 6:28:37 PM io.vertx.ext.asyncsql.impl.PostgreSQLClientImpl
INFO: Creating configuration for localhost:4040
Aug 31, 2020 6:28:38 PM io.vertx.core.impl.launcher.commands.VertxIsolatedDeployer
INFO: Succeeded in deploying verticle
Aug 31, 2020 6:28:38 PM io.vertx.core.impl.ContextImpl
SEVERE: Unhandled exception
rx.exceptions.OnErrorNotImplementedException: Address already in use
at rx.functions.Actions$NotImplemented.call(Actions.java:576)
at rx.functions.Actions$NotImplemented.call(Actions.java:572)
at rx.Single$11.onError(Single.java:1794)
at io.vertx.rx.java.SingleOnSubscribeAdapter.lambda$call$0(SingleOnSubscribeAdapter.java:33)
at io.vertx.rxjava.core.http.HttpServer$6.handle(HttpServer.java:312)
at io.vertx.rxjava.core.http.HttpServer$6.handle(HttpServer.java:307)
at io.vertx.core.http.impl.HttpServerImpl.lambda$null$4(HttpServerImpl.java:350)
at io.vertx.core.impl.ContextImpl.executeTask(ContextImpl.java:320)
at io.vertx.core.impl.EventLoopContext.lambda$executeAsync$0(EventLoopContext.java:38)
at io.netty.util.concurrent.AbstractEventExecutor.safeExecute$$$capture(AbstractEventExecutor.java:163)
at io.netty.util.concurrent.AbstractEventExecutor.safeExecute(AbstractEventExecutor.java)
at io.netty.util.concurrent.SingleThreadEventExecutor.runAllTasks(SingleThreadEventExecutor.java:404)
at io.netty.channel.nio.NioEventLoop.run(NioEventLoop.java:495)
at io.netty.util.concurrent.SingleThreadEventExecutor$5.run(SingleThreadEventExecutor.java:905)
at io.netty.util.concurrent.FastThreadLocalRunnable.run(FastThreadLocalRunnable.java:30)
at java.lang.Thread.run(Thread.java:748)
Caused by: java.net.BindException: Address already in use
at sun.nio.ch.Net.bind0(Native Method)
at sun.nio.ch.Net.bind(Net.java:433)
at sun.nio.ch.Net.bind(Net.java:425)
at sun.nio.ch.ServerSocketChannelImpl.bind(ServerSocketChannelImpl.java:223)
at io.netty.channel.socket.nio.NioServerSocketChannel.doBind(NioServerSocketChannel.java:130)
at io.netty.channel.AbstractChannel$AbstractUnsafe.bind(AbstractChannel.java:563)
at io.netty.channel.DefaultChannelPipeline$HeadContext.bind(DefaultChannelPipeline.java:1332)
at io.netty.channel.AbstractChannelHandlerContext.invokeBind(AbstractChannelHandlerContext.java:488)
at io.netty.channel.AbstractChannelHandlerContext.bind(AbstractChannelHandlerContext.java:473)
at io.netty.channel.DefaultChannelPipeline.bind(DefaultChannelPipeline.java:984)
at io.netty.channel.AbstractChannel.bind(AbstractChannel.java:259)
at io.netty.bootstrap.AbstractBootstrap$2.run(AbstractBootstrap.java:366)
at io.netty.util.concurrent.AbstractEventExecutor.safeExecute$$$capture(AbstractEventExecutor.java:163)
at io.netty.util.concurrent.AbstractEventExecutor.safeExecute(AbstractEventExecutor.java)
at io.netty.util.concurrent.SingleThreadEventExecutor.runAllTasksFrom(SingleThreadEventExecutor.java:380)
at io.netty.util.concurrent.SingleThreadEventExecutor.runAllTasks(SingleThreadEventExecutor.java:355)
at io.netty.channel.nio.NioEventLoop.run(NioEventLoop.java:486)
... 3 more

Could not invoke method getObjectInstance on object of type com.ibm.ws.naming.urlns.genericURLContextFactory error on JNDI lookup

Do you know why I'm getting this exception ?
String url = "corbaloc:iiop:localhost:2809";
String initial = "com.ibm.websphere.naming.WsnInitialContextFactory";
String jndi = "ejblocal:my/ejb/PeriodoBO";
Hashtable<String, String> pdEnv = new Hashtable<String, String>();
pdEnv.put("java.naming.provider.url", url);
pdEnv.put("java.naming.factory.initial", initial);
Context initialContext = new InitialContext(pdEnv);
try{
Object ejbHome = initialContext.lookup(jndi); // <-- here
Object obj = PortableRemoteObject.narrow(ejbHome, PeriodoBO.class);
}catch(NamingException e){
System.err.println(e.toString());
}
I'm sure that the JNDI is ok, I was struggling to get it (What's the default JNDI name of an EJB in Websphere Application Server 7 (WAS)?).
Could you help me please?
This is my run configuration :
UPDATE, I have just got the stack trace, I'm analyzing it :
WSCL0910I: Initializing component: com.ibm.ws.websvcs.component.WASAxis2ClientImpl
WSCL0911I: Component initialized successfully.
WSCL0910I: Initializing component: com.ibm.ejs.jms.JMSClientRegistration
WSCL0911I: Component initialized successfully.
WSCL0901I: Component initialization completed successfully.
WSCL0035I: Initialization of the Java EE Application Client Environment has completed.
WSCL0014I: Invoking the Application Client class xxxxx.tests.AllTests
.[02/06/14 17:21:45:963 COT] 00000000 W UOW=1-46884688-4040963:dmflores source=com.ibm.websphere.naming.genericURLInitialContextFactory org=IBM prod=WebSphere component=Application Server thread=[P=704708:O=0:CT]
NMSV0907E: Could not invoke method "getObjectInstance" on object of type "com.ibm.ws.naming.urlns.genericURLContextFactory".
E.
Time: 0,011
There was 1 error:
1) testCursosLlevados(xxxxx.CursosTest)javax.naming.ConfigurationException: Could not invoke method getObjectInstance on object of type com.ibm.ws.naming.urlns.genericURLContextFactory. [Root exception is java.lang.reflect.InvocationTargetException]
at com.ibm.websphere.naming.genericURLInitialContextFactory.getAndInvokeMethod(genericURLInitialContextFactory.java:480)
at com.ibm.websphere.naming.genericURLContextFactory.getObjectInstance(genericURLContextFactory.java:165)
at javax.naming.spi.NamingManager.getURLContext(Unknown Source)
at javax.naming.InitialContext.getURLOrDefaultInitCtx(Unknown Source)
at javax.naming.InitialContext.lookup(Unknown Source)
at xxxxxxx.tests.CursosTest.testCursosLlevados(CursosTest.java:59)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:45)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:37)
at xxxxxx.tests.AllTests.main(AllTests.java:17)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:45)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:37)
at com.ibm.ws.client.applicationclient.launchClient.createContainerAndLaunchApp(launchClient.java:797)
at com.ibm.ws.client.applicationclient.launchClient.main(launchClient.java:502)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:45)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:37)
at com.ibm.wsspi.bootstrap.WSLauncher.launchMain(WSLauncher.java:213)
at com.ibm.wsspi.bootstrap.WSLauncher.main(WSLauncher.java:93)
at com.ibm.wsspi.bootstrap.WSLauncher.run(WSLauncher.java:74)
at org.eclipse.core.internal.runtime.PlatformActivator$1.run(PlatformActivator.java:78)
at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.runApplication(EclipseAppLauncher.java:92)
at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.start(EclipseAppLauncher.java:68)
at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:400)
at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:177)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:45)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:37)
at org.eclipse.core.launcher.Main.invokeFramework(Main.java:340)
at org.eclipse.core.launcher.Main.basicRun(Main.java:282)
at org.eclipse.core.launcher.Main.run(Main.java:981)
at com.ibm.wsspi.bootstrap.WSPreLauncher.launchEclipse(WSPreLauncher.java:341)
at com.ibm.wsspi.bootstrap.WSPreLauncher.main(WSPreLauncher.java:111)
Caused by: java.lang.reflect.InvocationTargetException
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:45)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:37)
at com.ibm.websphere.naming.genericURLInitialContextFactory.getAndInvokeMethod(genericURLInitialContextFactory.java:466)
... 49 more
Caused by: javax.naming.ConfigurationException: There is no name space
at com.ibm.ws.naming.urlns.genericURLContextFactory.isNameSpaceAccessable(genericURLContextFactory.java:96)
at com.ibm.ws.naming.urlbase.UrlContextFactory.getObjectInstance(UrlContextFactory.java:84)
... 54 more
ejblocal:my/ejb/PeriodoBO points to the local interface. Local interface cannot be accessed by the Java EE Application Client. You need the Remote interface.
Add #Remote with correct interface to your bean. Then during app initialization you will find in the SystemOut.log binding name to which the interface was bound in the JNDI.
Then in initialContext.lookup(jndi); use that JNDI name.
Hope it helps
As this code is invoked from within a Java EE Application Client, and the Java EE Application Client is launched by the WAS libraries, much of the code you have there is unneeded and might as well be the reason for your problems. Try this:
String jndi = "ejblocal:my/ejb/PeriodoBO";
Context initialContext = new InitialContext();
Object ejbHome = initialContext.lookup(jndi);
Object obj = PortableRemoteObject.narrow(ejbHome, PeriodoBO.class);
EDIT to that, add #Gas's solution (which really addresses the root of your problem).

Jini (Apache River) cannot initialize Reggie (Lookup Service) script

I know Jini (Apache River) is a pretty old and outdated technology, but I need it for an university project.
The problem is I cannot even start the lookup service script (jrmp-reggie.sh). Executing the httpd.sh works good.
Any advice? Thanks.
By the way, here is the output I'm getting:
+ java -Djava.security.policy=config/start.policy -Djava.ext.dirs=../../lib-ext/ -jar ../../lib/start.jar config/start-reggie.config
Jun 14, 2013 8:19:51 PM com.sun.jini.reggie.RegistrarImpl <init>
SEVERE: Reggie initialization failed
java.lang.ExceptionInInitializerError
at net.jini.config.AbstractConfiguration.getEntryInternal(AbstractConfiguration.java:371)
at net.jini.config.AbstractConfiguration.getEntry(AbstractConfiguration.java:193)
at com.sun.jini.reggie.RegistrarImpl.init(RegistrarImpl.java:4554)
at com.sun.jini.reggie.RegistrarImpl.access$000(RegistrarImpl.java:143)
at com.sun.jini.reggie.RegistrarImpl$1.run(RegistrarImpl.java:448)
at com.sun.jini.reggie.RegistrarImpl.loginAndRun(RegistrarImpl.java:461)
at com.sun.jini.reggie.RegistrarImpl.<init>(RegistrarImpl.java:396)
at com.sun.jini.reggie.TransientRegistrarImpl.<init>(TransientRegistrarImpl.java:39)
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:525)
at com.sun.jini.start.NonActivatableServiceDescriptor.create(NonActivatableServiceDescriptor.java:674)
at com.sun.jini.start.ServiceStarter.create(ServiceStarter.java:287)
at com.sun.jini.start.ServiceStarter.processServiceDescriptors(ServiceStarter.java:445)
at com.sun.jini.start.ServiceStarter.main(ServiceStarter.java:476)
Caused by: java.lang.RuntimeException: Unexpected exception
at com.sun.jini.logging.Levels.createLevel(Levels.java:142)
at com.sun.jini.logging.Levels.<clinit>(Levels.java:52)
... 16 more
Caused by: java.io.EOFException
at java.io.ObjectInputStream$BlockDataInputStream.peekByte(ObjectInputStream.java:2596)
at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1316)
at java.io.ObjectInputStream.defaultReadFields(ObjectInputStream.java:1989)
at java.io.ObjectInputStream.readSerialData(ObjectInputStream.java:1913)
at java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:1796)
at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1348)
at java.io.ObjectInputStream.readObject(ObjectInputStream.java:370)
at com.sun.jini.logging.Levels.createLevel(Levels.java:138)
... 17 more
Jun 14, 2013 8:19:51 PM com.sun.jini.start.ServiceStarter checkResultFailures
WARNING: Exception creating service.
java.lang.reflect.InvocationTargetException
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:525)
at com.sun.jini.start.NonActivatableServiceDescriptor.create(NonActivatableServiceDescriptor.java:674)
at com.sun.jini.start.ServiceStarter.create(ServiceStarter.java:287)
at com.sun.jini.start.ServiceStarter.processServiceDescriptors(ServiceStarter.java:445)
at com.sun.jini.start.ServiceStarter.main(ServiceStarter.java:476)
Caused by: java.lang.ExceptionInInitializerError
at net.jini.config.AbstractConfiguration.getEntryInternal(AbstractConfiguration.java:371)
at net.jini.config.AbstractConfiguration.getEntry(AbstractConfiguration.java:193)
at com.sun.jini.reggie.RegistrarImpl.init(RegistrarImpl.java:4554)
at com.sun.jini.reggie.RegistrarImpl.access$000(RegistrarImpl.java:143)
at com.sun.jini.reggie.RegistrarImpl$1.run(RegistrarImpl.java:448)
at com.sun.jini.reggie.RegistrarImpl.loginAndRun(RegistrarImpl.java:461)
at com.sun.jini.reggie.RegistrarImpl.<init>(RegistrarImpl.java:396)
at com.sun.jini.reggie.TransientRegistrarImpl.<init>(TransientRegistrarImpl.java:39)
... 8 more
Caused by: java.lang.RuntimeException: Unexpected exception
at com.sun.jini.logging.Levels.createLevel(Levels.java:142)
at com.sun.jini.logging.Levels.<clinit>(Levels.java:52)
... 16 more
Caused by: java.io.EOFException
at java.io.ObjectInputStream$BlockDataInputStream.peekByte(ObjectInputStream.java:2596)
at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1316)
at java.io.ObjectInputStream.defaultReadFields(ObjectInputStream.java:1989)
at java.io.ObjectInputStream.readSerialData(ObjectInputStream.java:1913)
at java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:1796)
at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1348)
at java.io.ObjectInputStream.readObject(ObjectInputStream.java:370)
at com.sun.jini.logging.Levels.createLevel(Levels.java:138)
... 17 more
Jun 14, 2013 8:19:51 PM com.sun.jini.start.ServiceStarter checkResultFailures
WARNING: Associated service descriptor [0]: [http://t420:8080/reggie-dl.jar http://t420:8080/jsk-dl.jar, config/reggie.policy, ../../lib/reggie.jar, com.sun.jini.reggie.TransientRegistrarImpl, [config/jrmp-reggie.config], com.sun.jini.start.NonActivatableServiceDescriptor$1#c27ce4, BasicProxyPreparer[]]
This looks like the same error I have seen when upgrading the JDK. Try JDK 1.6.0_38 (if you are using a higher version). Also the Apache River project did come across this issue and appeared to have a workaround which involves changing Levels.java
https://issues.apache.org/jira/browse/RIVER-415
Regards
Rod
Sounds like you didn't start rmid possibly.
I guess the Reggie script attempts to gain access to configuration files, but it cant!
If the script is located in: river/examples/hello/scripts
Copy it on folder higher. I mean river/examples/hello/
Then, run it. Just let me know about your output. You are using 'sh' file. But, do not use the 'bat' file. Let me know the result.

Error while making webservice call

I am accessing a webservice exposed by some other guy as a client using axis2 and I have made a wrapper method for abcStub .java (Stub java file made by running some batch) and tried to instantiate the Stub file inside the wrapper java file. But i get following errors:
INFO: ERROR org.apache.struts.actions.DispatchAction - Dispatch[/remittanceTransaction] to method 'remTransApprove' returned an exception
java.lang.reflect.InvocationTargetException
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:601)
Caused by: java.lang.NoSuchMethodError: org.apache.neethi.PolicyEngine.getPolicy(Ljava/lang/Object;)Lorg/apache/neethi/Policy;
at org.tempuri.MIRSRemittanceServicesStub.getPolicy(MIRSRemittanceServicesStub.java:3558)
at org.tempuri.MIRSRemittanceServicesStub.populateAxisService(MIRSRemittanceServicesStub.java:57)
at org.tempuri.MIRSRemittanceServicesStub.(MIRSRemittanceServicesStub.java:268)
at org.tempuri.MIRSRemittanceServicesStub.(MIRSRemittanceServicesStub.java:257)
at org.tempuri.MIRSRemittanceServicesStub.(MIRSRemittanceServicesStub.java:305)
INFO: g.tempuri.MIRSRemittanceServicesStub.(MIRSRemittanceServicesStub.java:297)
at com.mtmrs.webservice.MIRSRemittanceTransactionManagerImpl.getAppDeclWrapper(MIRSRemittanceTransactionManagerImpl.java:201)
at com.mtmrs.business.backoffice.impl.RemittanceTransactionManagerImpl.remTransApprove(RemittanceTransactionManagerImpl.java:1417)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at com.mtmrs.application.backoffice.action.RemittanceTransactionAction.remTransApprove(RemittanceTransactionAction.java:1409)
... 78 more
INFO: WARN org.apache.struts.action.RequestProcessor - Unhandled Exception thrown: class javax.servlet.ServletException
WARNING: StandardWrapperValve[action]: PWC1406: Servlet.service() for servlet action threw exception
java.lang.NoSuchMethodError: org.apache.neethi.PolicyEngine.getPolicy(Ljava/lang/Object;)Lorg/apache/neethi/Policy;
at org.tempuri.MIRSRemittanceServicesStub.getPolicy(MIRSRemittanceServicesStub.java:3558)
at org.tempuri.MIRSRemittanceServicesStub.populateAxisService(MIRSRemittanceServicesStub.java:57)
at org.tempuri.MIRSRemittanceServicesStub.(MIRSRemittanceServicesStub.java:268)
I think there must be problem with this
org.apache.neethi.PolicyEngine.getPolicy(Ljava/lang/Object;)Lorg/apache/neethi/Policy;
or may be im wrong. Either way, dunno how to fix. Would be of much help if anyone knew of faced/solved this before.
I got this while making following call:
public String getAppDeclWrapper(String session, String parentAgent, String mirsTxnNo, String strReason, String isApprove, String modifiedBY){
String returnString = null;
try {
mtmrsLogger.info("Entering into Approve Decline procedure, Starting to send Status to MIRS");
MIRSRemittanceServicesStub stub = new MIRSRemittanceServicesStub(); //Error occurs at this line
ApproveDecline approvedEcline = new ApproveDecline();
ApproveDeclineResponse approveResponse = new ApproveDeclineResponse();
approvedEcline.setCParentAgent(parentAgent);
approvedEcline.setMirsSession(session);
approvedEcline.setModifiedBy(modifiedBY);
approvedEcline.setRefNo(mirsTxnNo);
approvedEcline.setStrReason(strReason);
approvedEcline.setIsApprove(isApprove);
My guess is you have multiple versions (or invalid version) of PolicyEngine on your classpath. I think you are running inside a servlet engine. Try following code to determine where this version is stored and fix it:
org.apache.neethi.PolicyEngine.class.getProtectionDomain().getCodeSource().getLo‌​cation()

Error generating web services through the Apache CXF framework

I am trying to generate web services in Eclipse by using the Apache CXF framework.
First I am creating the Java class corresponding to the desired web service and then I generate two dynamic web projects, one for the web service (wsdl file) and another one for the clients. The web web services work well after I create them but after some time (one-three days) I get the error displayed in the image at the server startup.
INFO: Starting service Catalina
Dec 7, 2011 9:27:55 PM org.apache.catalina.core.StandardEngine startInternal
INFO: Starting Servlet Engine: Apache Tomcat/7.0.4
Dec 7, 2011 9:27:55 PM org.apache.catalina.loader.WebappClassLoader validateJarFile
INFO: validateJarFile(C:\Documents and Settings\user\workspace\.metadata\.plugins\org.eclipse.wst.server.core\tmp0\wtpwebapps\Prosys_Doctorat_Servicii_FAS_servicii\WEB-INF\lib\geronimo-servlet_3.0_spec-1.0.jar) - jar not loaded. See Servlet Spec 2.3, section 9.7.2. Offending class: javax/servlet/Servlet.class
Dec 7, 2011 9:27:59 PM org.apache.catalina.core.StandardContext listenerStart
SEVERE: Error configuring application listener of class org.springframework.web.context.ContextLoaderListener
java.lang.ClassNotFoundException: org.springframework.web.context.ContextLoaderListener
at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1672)
at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1517)
at org.apache.catalina.core.DefaultInstanceManager.loadClass(DefaultInstanceManager.java:415)
at org.apache.catalina.core.DefaultInstanceManager.loadClassMaybePrivileged(DefaultInstanceManager.java:397)
at org.apache.catalina.core.DefaultInstanceManager.newInstance(DefaultInstanceManager.java:118)
at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4287)
at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:4816)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:140)
at org.apache.catalina.core.ContainerBase.startInternal(ContainerBase.java:1028)
at org.apache.catalina.core.StandardHost.startInternal(StandardHost.java:773)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:140)
at org.apache.catalina.core.ContainerBase.startInternal(ContainerBase.java:1028)
at org.apache.catalina.core.StandardEngine.startInternal(StandardEngine.java:278)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:140)
at org.apache.catalina.core.StandardService.startInternal(StandardService.java:429)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:140)
at org.apache.catalina.core.StandardServer.startInternal(StandardServer.java:662)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:140)
at org.apache.catalina.startup.Catalina.start(Catalina.java:592)
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.catalina.startup.Bootstrap.start(Bootstrap.java:290)
at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:418)
Dec 7, 2011 9:27:59 PM org.apache.catalina.core.StandardContext listenerStart
SEVERE: Skipped installing application listeners due to previous error(s)
Dec 7, 2011 9:27:59 PM org.apache.catalina.core.StandardContext startInternal
Then when I try to call a web service from the project I get the following error:
Exception in thread "main" javax.xml.ws.WebServiceException: org.apache.cxf.service.factory.ServiceConstructionException: Failed to create service.
at org.apache.cxf.jaxws.ServiceImpl.<init>(ServiceImpl.java:149)
at org.apache.cxf.jaxws.spi.ProviderImpl.createServiceDelegate(ProviderImpl.java:90)
at javax.xml.ws.Service.<init>(Unknown Source)
at read_variable_value.ReadVariableNodeService1Service.<init>(ReadVariableNodeService1Service.java:50)
at FAS.Model2_FAS.asociere_valori(Model2_FAS.java:206)
at FAS.Model2_FAS.main(Model2_FAS.java:2596)
Caused by: org.apache.cxf.service.factory.ServiceConstructionException: Failed to create service.
at org.apache.cxf.wsdl11.WSDLServiceFactory.<init>(WSDLServiceFactory.java:93)
at org.apache.cxf.jaxws.ServiceImpl.initializePorts(ServiceImpl.java:203)
at org.apache.cxf.jaxws.ServiceImpl.<init>(ServiceImpl.java:147)
... 5 more
Caused by: javax.wsdl.WSDLException: WSDLException: faultCode=PARSER_ERROR: Problem parsing 'http://localhost:8081/Prosys_Doctorat_Servicii_FAS_servicii/services/ReadVariableNodeService1Port?wsdl'.: java.io.FileNotFoundException: http://localhost:8081/Prosys_Doctorat_Servicii_FAS_servicii/services/ReadVariableNodeService1Port?wsdl
at com.ibm.wsdl.xml.WSDLReaderImpl.getDocument(Unknown Source)
at com.ibm.wsdl.xml.WSDLReaderImpl.readWSDL(Unknown Source)
at com.ibm.wsdl.xml.WSDLReaderImpl.readWSDL(Unknown Source)
at org.apache.cxf.wsdl11.WSDLManagerImpl.loadDefinition(WSDLManagerImpl.java:239)
at org.apache.cxf.wsdl11.WSDLManagerImpl.getDefinition(WSDLManagerImpl.java:186)
at org.apache.cxf.wsdl11.WSDLServiceFactory.<init>(WSDLServiceFactory.java:91)
... 7 more
Caused by: java.io.FileNotFoundException: http://localhost:8081/Prosys_Doctorat_Servicii_FAS_servicii/services/ReadVariableNodeService1Port?wsdl
at sun.net.www.protocol.http.HttpURLConnection.getInputStream(Unknown Source)
at com.sun.org.apache.xerces.internal.impl.XMLEntityManager.setupCurrentEntity(Unknown Source)
at com.sun.org.apache.xerces.internal.impl.XMLVersionDetector.determineDocVersion(Unknown Source)
at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(Unknown Source)
at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(Unknown Source)
at com.sun.org.apache.xerces.internal.parsers.XMLParser.parse(Unknown Source)
at com.sun.org.apache.xerces.internal.parsers.DOMParser.parse(Unknown Source)
at com.sun.org.apache.xerces.internal.jaxp.DocumentBuilderImpl.parse(Unknown Source)
... 13 more
What can cause this error which only appears after the web services are used repeatedly?
http://i.stack.imgur.com/4mTNZ.jpg
http://i.stack.imgur.com/rYkQb.jpg
Hi, the client is automatically generated in the following way:
private static final QName SERVICE_NAME = new QName("http://read_variable/", "ReadVariableNodeServiceService");
URL wsdlURL = ReadVariableNodeServiceService.WSDL_LOCATION;
ReadVariableNodeServiceService ss = new ReadVariableNodeServiceService(wsdlURL, SERVICE_NAME);
SEIReadValue port = ss.getReadVariableNodeServicePort();
{
System.out.println("Invoking getValue...");
java.lang.String _getValue_arg0 = "Alina";
java.lang.String _getValue_arg1 = "WorkspaceS1";
try {
double _getValue__return = port.getValue(_getValue_arg0, _getValue_arg1);
System.out.println("getValue.result=" + _getValue__return);
................
Last week I have found an interesting documentation which recommends the following way to call a web service:
ClassPathXmlApplicationContext context=new ClassPathXmlApplicationContext(new String[]{"read_variable/client3_beans.xml"});
SEIReadValue port = (SEIReadValue) context.getBean("readvariableClient");
{
System.out.println("Invoking getValue...");
java.lang.String _getValue_arg0 = "Alina";
java.lang.String _getValue_arg1 = "WorkspaceS1";
try {
double _getValue__return = port.getValue(_getValue_arg0, _getValue_arg1);
System.out.println("getValue.result=" + _getValue__return);
.........
What do you think? May this be the reason for my error?
I am very happy that I have almost found out the cause of my error. But I am a beginner in web services and I haven't understood your message entirely.
I want to specify that I have a set of basic/simple web services, and then based on these web services I have created a complex web service where I obtain the context
of each simple web service in order to obtain its functionality, and as you said (as I understood) this is not the right approach.
ClassPathXmlApplicationContext context=new ClassPathXmlApplicationContext(new String[]{"write_a_matrix/client2_beans.xml"});
SEIWriteMatrix port = (SEIWriteMatrix) context.getBean("write_a_matrix_Client");
...........................................................
ClassPathXmlApplicationContext context_WV=new ClassPathXmlApplicationContext(new String[]{"write_value/client1_beans.xml"});
SEIWriteValue port_WV = (SEIWriteValue) context_WV.getBean("write_a_value_Client");
...........................................................
I have created a client_beans xml file for each web service client. Is it ok? Can you provide me an example of how to call a web service and the way to hold just one App context?
I will provide you my email address < berlindutza#yahoo.com > in case you want to communicate much easier because I have seen that we are limited to a certain number of characters (for the add comment section).
Thank you a lot!
Guessing here: You are probably recreating the CXF client for every request, instead of creating it once, keeping it as a singleton and using this one instance for every subsequent request.
Ideally you should be able to generate the client using the webservice interface. If you have explicitly specified a wsdl, cxf will generate a proxy based on the WSDL, which is what seems to be happening for you. Once in a while the service which serves out the wsdl fails and you get this error.
If you are using Spring, you can do something along these lines:
<bean id="clientFactory" class="org.apache.cxf.jaxws.JaxWsProxyFactoryBean">
<property name="serviceClass" value="...wsInterface" />
<property name="address" value="serviceURL" />
</bean>
<bean id="client" class="...wsInterface" factory-bean="clientFactory" factory-method="create" />

Categories