java.xml.namepsace error - SOAP (Webservice) in Java - eclipse

I have no experience with WebService, especially SOAP, but I have to deal with it. I work with Java 11 and with the latest Eclipse IDE. In the beginning I read a lot and also developed my own WebService. This service can only calculate the BMI. There are no errors in this service on the server side.
I had the client automatically generated with the Java API for XML Webservices. However, several errors are displayed in the generated classes.
First Error:
"The package javax.xml.namespace is accessible from more than one module: java.xml, jaxrpc"
If I try to fix the error, then there is a new error. Let's get back to trying to fix the bug. In some other forums I have read that in the module information "module-info.java" the "requires java.xml" should be commented out. The error seems to disappear for now, but it leads to two new errors:
"The type javax.xml.namespace.QName is not accessible" and "The type javax.xml.namespace.QName cannot be resolved. It is indirectly referenced from required .class files"
Here are a few code:
module Client {
exports ws;
requires axis;
requires java.instrument;
requires java.logging;
requires java.management;
requires java.naming;
requires java.net.http;
requires java.prefs;
requires java.rmi;
//requires java.xml;
requires jaxrpc;}
Here is a example of the DemolmplServiceLocater where java.xml.namepace are underlined red:
public DemolmplServiceLocator(java.lang.String wsdlLoc, javax.xml.namespace.QName sName) throws javax.xml.rpc.ServiceException {
super(wsdlLoc, sName);
}
This is the class DemolmplService.java with the second error and "fixed" first error.
The lost one ist the Build Path from my project.
Among other things I opened a client in Java-SE1.8 project and tried out the client there. There no error was displayed and the method bmi(weight,height) was executed successfully. But I need the project at least in Java 10 or higher.
Can anyone offer me a solution, preferably a step-by-step guide?
I thank you in advance!

Related

Getting SLF4JLogFactory exception while trying to access web services from Confluence 3.0

I have been able to understand about the dependencies and procedures to add Jar files into a Confluence project with the help of a friend from here.
But I am facing an error with the addition of these JAR's.
The exact cause of the error seen is :
javax.servlet.ServletException: Servlet execution threw an exception
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:313)
caused by: java.lang.ExceptionInInitializerError
at org.apache.axis.attachments.AttachmentsImpl.<clinit>(AttachmentsImpl.java:39)
caused by: java.lang.ClassCastException: org.apache.commons.logging.impl.SLF4JLogFactory cannot be cast to org.apache.commons.logging.LogFactory
at org.apache.axis.components.logger.LogFactory.getLogFactory(LogFactory.java:41)
What I am trying to do is :
Write a custom plugin.
Modify the UI so that I can accept user entered values say For Eg Credentials.
Use those credentials and hit a web service method and obtain a ticket for the valid user.
Now I can only consume the web services I do not have the authority to modify them. As a result it does work with 8 essential jars. Of these the ones which I use not created by me are the
popular ones.
commons-discovery 0.2
commons-logging 1.1
jaxrpc 1.0
log4j 1.0
wsdl4j
1.0 axis 1.4
If i use axis 1.2.1 instead of 1.4 ; i get the error .
Exception in thread "main" java.lang.NoSuchMethodError: org.apache.axis.description.ParameterDesc.setOmittable(Z)V
But using axis 1.4 gives me the required ticket in my local NON CONFLUENCE test sample Java project.
(I am putting my code in paste bin lest the question becomes extremely long)
This is my POM.xml
This is the class I have written. I have in fact been able to add my custom tab in the 'Advanced' area and clicking on the tab triggers the execute method.
This is the error I am seeing on the resulting System Error (the one with the title Oops - an error has occured.)
Would like to have any hints from you which can greatly help understand what needs to be done to get out of this error.
I am sure calling web services from Confluence must be a not a complex chore. Is it the combination of JAR's I am reliant on that's giving me the trouble. Any leads to the same will be immensely helpful.
Atlassian forked the axis library and Jira now uses axis-1.3-atlassian-1 and not the latest axis-1.4 from Apache; axis-1.3-atlassian-1 uses the 1.0.4 version of commons-logging, not 1.1.1 like axis-1.4.
Changing the dependency of the plugin from axis-1.4 to axis-1.3-atlassian-1 solved a similar problem for me. It is my suspicion that SLF4JLogFactory could cast to org.apache.commons.logging.LogFactory in 1.0.4 but not 1.1.1, but I haven't tested that.
Edit: here's where you can get the jar and source.

Using Soap in Shared Mono Library for WP 7 and Android

I'm currently working on an shared library based on mono, where I want to put as much business logic of my app as possible.
I used this helpful tutorial.
I managed putting the whole logic for rest-requests in this shared library, but now I'm stuck with soap.
I used the wsdl command of mono to generate Client Stubcode from my wsdl (as described here http://www.mono-project.com/Web_Services).
When I put the generated class to my C# library, which is the root project of my shared library, there is a warning that the Reference to System.Web.Services cannot be found.
So I included the System.Web.Services.dll manually.
For the Android Library Project I added a Reference to ...\Reference Assemblies\Microsoft\Framework\MonoAndroid\v1.0\System.Web.Services.dll. It compiles without warnings.
But now it comes to the Windows Phone Library Project.
There is no System.Web.Services.dll for WP 7.5, right? I tried with the Mono-Touch dll but it gives me a lot compilation Errors.
Someone knows how I can get out of this?
I actually had some issues with the generated WSDL myself. Turns out that the classes that were generated through the "Create Web Reference" piece of Visual Studio inside of a Mono for Android project ended up causing some big issues when connected to a WCF Web Service. Not sure where I ran into this information, but this is what I ended up doing.
What you need to do is manually create a Service Reference using the SILVERLIGHT SVCUtil.
On my development system it was located here:
C:\Program Files (x86)\Microsoft SDKs\Silverlight\v3.0\Tools
I called it with the below command line:
slsvcutil.exe http://localhost/<path to WCF service endpoint>/service.svc /directory:"<temp directory to store generated cs file>" /noConfig /namespace:"*,<Full namespace of the generated class>"
That will actually generate a CS file that is saved into the path specified by the /directory tag above. Copy that generated cs file to your project directory and then include it in the project.
The problem that I was having that forced me to look for another option was that I was able to pull the data properly using the WSDL generated through the "Add Web Reference" option in Visual Studio, but as soon as I tried to pass the data back up the wire to the web service, everything blew up. Using the Service Reference generated by the Silverlight Service Util actually generated all the code properly for Async operations and after learning how to properly manage those Async operations everything works like a dream.
Since you are generating this new WSDL using the Silverlight Utility, it should work just fine through Windows Phone 7. I believe that the DLL to reference for all of this is the System.ServiceModel dll.
I wish I could remember where I ran across this information, as I would like to give the original author credit, but unfortunately, I don't recall that.
Hope that helps out!
Chaitanya Marvici

trouble with service reference

I added a service reference that points to http://api.microsofttranslator.com/V1/soap.svc in my project. After adding the reference an app.config file was created.
When I run the project everything works. After creating a setup file with Advanced Installer (program for authoring Windows Installer setup packages) I get the following error message when I run the installed program.
"Could not find default endpoint element that references contract TranslatorService.LanguageService in the ServiceModel client configuration section. This might be because no configuration file was found for your application, or because no endpoint element matching this contract could be found in the client element."
Can someone help?
This problem is not generated by the setup package created with Advanced Installer, it seems to be .NET specific. Here is another similar thread: Microsoft translator error

Strange GWT Error with external jar on server side

I want to use a external jar (Apache Mahout) on the server side of my GWT Applicatopn.
As far as i know using external jars on the server side shouldn't cause an error. Only on the client side but when i try to run the code i get the following error:
"no source code is available for de.unimannheim.paniscus.server..."
Whats wrong here ?
Please help me i need to solve this for my thesis
Hi guys i created now an collbaorative.gwt.xml where i inherited all classes from apache mahout that are used within de.unimannheim.paniscus.server.collaborative but it's still not working. Sorry i'm helpless whats wrong here ?
I agree with Dusty Campbell, you should not inherit the jar in the *.gwt.xml. The <inherits> tag in the *.gwt.xml specifies gwt-modules which should be inherited. So only client-side-compatible code can be inherited.
Citation from the gwt docs: "<inherits name="logical-module-name" /> : Inherits all the settings from the specified module as if the contents of the inherited module's XML were copied verbatim. Any number of modules can be inherited in this manner"
see also: http://code.google.com/webtoolkit/doc/1.6/DevGuideOrganizingProjects.html#DevGuideInheritingModules
My guess is that you (by mistake) use a class from the "de.unimannheim.paniscus.server" package in client-side or shared code. Even just an import statement (import de.unimannheim.paniscus.server.*) will cause this exception.

Second compilation of same sources produces different set of gwt.rpc files

I would like to follow up on this question gwt-serialization-policy-hosted-mode-out-of-sync. In short - when I do a RPC from hosted browser then this call fails on server with the exception.
INFO: GwtRpcEventSrvc: ERROR: The serialization policy file '/84EC7BA65AF8175BAA99B47877FDE163.gwt.rpc' was not found; did you forget to include it in this deployment?
SEVERE: GwtRpcEventSrvc: WARNING: Failed to get the SerializationPolicy '84EC7BA65AF8175BAA99B47877FDE163' for module 'http://host:19980/MYAPP/'; a legacy, 1.3.3 compatible, serialization policy will be used. Youmay experience SerializationExceptions as a result.
SEVERE: Exception while dispatching incoming RPC call
While when I do the same RPC from browser then the request is performed successfully on server.
In addition I observed a strange behavior of GWT compiler that could result in a problem with hosted browser mode.
I assume when I do two subsequent compilations of an exact same code then the result of the individual compilations is supposed to be same. I mean at least the xxxxx.html and yyyyy.gwt.rpc files have to be same. (Where xxxxx and yyyyy are the long numbers such as 84EC7BA65AF8175BAA99B47877FDE163.)
Currently I have two versions of my project.
An old project compiled by GWT 1.7 that does not suffer from problem with the hosted browser described in gwt-serialization-policy-hosted-mode-out-of-sync
A new project that is compiled by GWT 2.0.4. This new project is based on the old project. This project suffer from the hosted browser problem.
Case 1: Old project with GWT 1.7
I took my old project that was compiled by GWT 1.7. I did two compilations and I compared compilation artifacts. gwt.rpc files were same while html files had different content and name. Since the gwt.rpc files were alwas same I did not have a problem with hosted browser.
Case 2: New project with GWT 2.0.4
I compiled it twice and both gwt.rpc and html files were different. Therefore RPC call in hosted browser failed on server because of missing gwt.rpc file.
Case 3: Old project with GWT 2.0.4
I compiled it twice and both gwt.rpc and html files were different. Therefore RPC call in hosted browser failed on server because of missing gwt.rpc file.
I did some investigation and identified that when I comment out a data member in a class Data that is transmitted from server to client, then compiled files start being same.
class Data implements IsSerializable {
List<IsSerializable> data;
...
}
I wanted to do same thing in the new project but it seems that there are many classes to be modified. So the problem is growing as the project is growing.
I don't know what to use instead of
List<IsSerializable> data;
to transfer data.
You need to read some more on GWT serialization policies:
Serializable Types
Usually you don't mingle with .rpc files unless your are doing advanced RPC calls directly to your server.
Your serializable object :
class Data implements IsSerializable {
List<IsSerializable> data;
...
}
A user-defined class is serializable if all of the following apply:
It is assignable to IsSerializable or Serializable, either because it directly implements one of these interfaces or because it derives from a superclass that does
All non-final, non-transient instance fields are themselves serializable, and
As of GWT 1.5, it must have a default (zero argument) constructor (with any access modifier) or no constructor at all.
So you should probably have something like:
class Data implements IsSerializable {
List<YOUR_TYPE> data;
...
}
Your list's template is a type, you don't set 'IsSerializable'... it should be something like :
List<int> data;