"org.apache.axis2.AxisFault: unknown" when calling web service with Java - java

I'm trying to call a web service with a Java client. The WSDL looks like this: http://pastebin.com/m13124ba
My client:
public class Client{
public static void main(java.lang.String args[]){
try{
CompileAndExecuteServiceInterfaceStub stub =
new CompileAndExecuteServiceInterfaceStub
("http://192.168.1.3:8080/axis2/services/CompileAndExecuteServiceInterface");
Compile comp = new Compile();
comp.setArgs0("Test");
comp.setArgs1("public class Test { public static void main(String[] args) { System.out.println(\"Hello\");}}");
String[] classpath = {};
comp.setArgs2(classpath);
stub.compile(comp);
} catch(Exception e){
e.printStackTrace();
}
}
}
When I run the client now the following error occurs:
org.apache.axis2.AxisFault: unknown
at org.apache.axis2.util.Utils.getInboundFaultFromMessageContext(Utils.java:517)
at org.apache.axis2.description.OutInAxisOperationClient.handleResponse(OutInAxisOperation.java:371)
at org.apache.axis2.description.OutInAxisOperationClient.send(OutInAxisOperation.java:417)
at org.apache.axis2.description.OutInAxisOperationClient.executeImpl(OutInAxisOperation.java:229)
at org.apache.axis2.client.OperationClient.execute(OperationClient.java:165)
at de.dax.compileandexecuteclient.CompileAndExecuteServiceInterfaceStub.compile(CompileAndExecuteServiceInterfaceStub.java:184)
at de.dax.compileandexecuteclient.Client.main(Client.java:17)</blockquote>
I tried out the business logic of the server on my local machine and there it works. The service creates files and folders. Are web services allowed to do that? I also wrote a simple "Hello World" web service and deployed it to the server. This worked fine.

When you get one of these "unknown" AxisFaults, definitely check the server log! The client-side stack trace most likely will not be detailed enough for you to track down the error.
I believe dax is indicating above that he found the NullPointerException in the more-detailed server side stack trace. It would look something like:
org.apache.axis2.AxisFault
at org.apache.axis2.AxisFault.makeFault(AxisFault.java:430)
[....]
Caused by: java.lang.NullPointerException
[....]

From the provided logs, I cannot determine what's wrong. Try to set the log-level of Axis2 to "debug" (see the two log-configurations in the root directory of your Axis2 installation) and check the details for the exact cause. Axis2 tends to be a bit sparse in propagating the errors coming from webservices.

The problem was that there was an NullPointerException in my service.

Related

Use of Java Smack 4.3.4 in a JUnit Testcase in Maven

I am working on a Java library with some services based on xmpp. For XMPP communication, I use Smack version 4.3.4. The development has so far been without problems and I have also created some test routines that can all be run without errors. After I migrated to a Maven project to generate a FatJar, I wanted to convert the executable test cases into JUnit tests. Unexpectedly, an error occurs, the reason of which I cannot explain. As I said, the code can be run outside of JUnit without any problems.
Below is the simplified test code (establishing a connection to the xmpp server):
#Test
public void connect()
{
Builder builder = XMPPTCPConnectionConfiguration.builder();
builder.setSecurityMode(SecurityMode.disabled);
builder.setUsernameAndPassword("iec61850client", "iec61850client");
builder.setPort(5222);
builder.setSendPresence(true);
try
{
builder.setXmppDomain("127.0.0.1");
builder.setHostAddress(InetAddress.getByName("127.0.0.1"));
}
catch (Exception e)
{
e.printStackTrace();
}
XMPPTCPConnectionConfiguration config = builder.build();
XMPPTCPConnection c = new XMPPTCPConnection(config);
c.setReplyTimeout(5000);
try
{
c.connect().login();
}
catch (Exception e)
{
e.printStackTrace();
}
}
And here is the error message I get:
Exception in thread "Smack Reader (0)" java.lang.AssertionError
at org.jivesoftware.smack.tcp.XMPPTCPConnection$PacketReader.parsePackets(XMPPTCPConnection.java:1154)
at org.jivesoftware.smack.tcp.XMPPTCPConnection$PacketReader.access$1000(XMPPTCPConnection.java:1092)
at org.jivesoftware.smack.tcp.XMPPTCPConnection$PacketReader$1.run(XMPPTCPConnection.java:1112)
In Smack it boils down to this 'assert' instruction:
assert (config.getXMPPServiceDomain().equals(reportedServerDomain));
Any idea what the problem might be or similar problems? I'm grateful for any help!
Thanks a lot,
Markus
If you look at the source code you will find that reportedServerDomain is extracted from the server's stream open tag. In this case the xmpp domain reported by the server does not match the one that is configured. This should usually not happen, but I assume it is related to the way you run the unit tests. Or more precisely, related to the remote server or mocked server that is used in the tests. If you enable smack's debug output, you will see the stream open tag and the 'from' attribute and its value. Compare this with the configured XMPP service domain in the ConnectionConfiguration.

TokenResponseException: missing scope when using the RemoteAPI of AppEngine in Java with OAuth 2.0 on stand-alone application

My goal is for my stand-alone application to access the datastore of a Google App Engine application so that I can query it. My application used to work with ClientLogin, but I have been asked to use OAuth 2.0 for the authentication (and using ClientLogin doesn't work anymore).
I follow the instructions on this page: https://cloud.google.com/appengine/docs/java/tools/remoteapi
I use the provided code, have made an service account, downloaded the json key, made an environment variable pointing to this key. The result is that I get the following exception:
Exception in thread "main" java.lang.ExceptionInInitializerError
at myApplication.myClass4.moveResultsOfFeature(myClass4.java:51)
at myApplication.myClass2.migrate(MyClass3.java:32)
at myApplication.myClass1.main(Starter.java:11)
Caused by: java.lang.RuntimeException: Failed to acquire Google Application Default credential.
at com.google.appengine.tools.remoteapi.RemoteApiOptions.useApplicationDefaultCredential(RemoteApiOptions.java:163)
at commonMigration.RemoteOptions.<clinit>(RemoteOptions.java:18)
... 3 more
Caused by: com.google.appengine.repackaged.com.google.api.client.auth.oauth2.TokenResponseException: 400 Bad Request
{
"error" : "invalid_scope",
"error_description" : "Empty or missing scope not allowed."
}
at com.google.appengine.repackaged.com.google.api.client.auth.oauth2.TokenResponseException.from(TokenResponseException.java:105)
at com.google.appengine.repackaged.com.google.api.client.auth.oauth2.TokenRequest.executeUnparsed(TokenRequest.java:287)
at com.google.appengine.repackaged.com.google.api.client.auth.oauth2.TokenRequest.execute(TokenRequest.java:307)
at com.google.appengine.repackaged.com.google.api.client.googleapis.auth.oauth2.GoogleCredential.executeRefreshToken(GoogleCredential.java:384)
at com.google.appengine.repackaged.com.google.api.client.auth.oauth2.Credential.refreshToken(Credential.java:489)
at com.google.appengine.tools.remoteapi.RemoteApiOptions.useApplicationDefaultCredential(RemoteApiOptions.java:160)
... 4 more
which seems to point to a missing scope argument, a concern which isn't mentioned in the explication on the web page. Is there an easy way to fix this issue?
Per request, my code (simplified):
public class StackOverflow {
private static RemoteApiOptions REMOTE_OPTIONS = new RemoteApiOptions().server(
<application-id>.appspot.com, 443)
.useApplicationDefaultCredential();
public static void main(String[] args0) throws IOException {
// MAKING THE CONNECTION
RemoteApiInstaller installer = new RemoteApiInstaller();
// LOAD FROM Local
installer.install(REMOTE_OPTIONS);
try {
// MY OPERATIONS
} finally {
installer.uninstall();
}
}
}
This is a current limitation of the Remote API. See the note here:
Note: The Remote API call to useApplicationDefaultCredential() can only use credentials provided by the gcloud command.
(It's possible you followed the instructions before the note was added, since it is a recently discovered limitation). The limitation will be fixed in a future release. For now, you should either run:
gcloud auth login
And use your user account to authenticate using useApplicationDefaultCredential(). Or, you can use a service account with .useServiceAccountCredential, which accepts the service account email and a path to a p12 file instead of the json file.

Restlet error. unable to run the following server-side task httpserver.serverimpl

My smartphone collects GPS, Bluetooth log, then periodically send the data to server.
My server continuously receive the data by using Restlet.
However i encounter a error which i have never seen before and Google does not give any solution or hints. (my server has worked well for the past few days.)
Following message is errors i encountered.
Unable to run the following server-side task: sun-net.httpserver.ServerImpl$Exchange#81a5dc
Unable to run the following server-side task: sun-net.httpserver.ServerImpl$Exchange#~~~~~~
Unable to run the following server-side task: sun-net.httpserver.ServerImpl$Exchange#~~~~~~
Following is my code.
RestletServerMain.java
public void restServer(){
try{
Component component = new Component();
component.getServers().add(Protocol.HTTP, Integer.parseInt(Common.SERVER_PORT));
component.getDefaultHost().attach(new ServerApplication());
component.start();
}catch(Exception e){
e.printStackTrace();
}
}
ServerApplication.java
public class ServerApplication extends Application {
public Restlet createInboundRoot() {
Router router = new Router(getContext());
router.attach("/dataprocessing1", xxx.class);
router.attach("/dataprocessing2", yyy.class);
return router;
}
It could be interesting to try the jetty extension (org.restlet.extends.jetty) of Restlet (instead of the default one).
Just add the corresponding jar file in your classpath and Jetty will be used as underlying server for your application.
Hope it will fix your issue.
Thierry

How to authenticate in Remedy using Java

I need to authenticate myself in Remedy. I'm following the documentation, but I still getting some errors.
https://communities.bmc.com/docs/DOC-17514
This is my code:
import com.bmc.arsys.api.ARException;
import com.bmc.arsys.api.ARServerUser;
public class Tutorial {
public static void main(String[] args) {
ARServerUser ctx = new ARServerUser();
ctx.setServer("127.0.0.1");
ctx.setUser("myusername");
ctx.setPassword("mypassword");
ctx.setPort(8080);
try {
ctx.verifyUser();
} catch (ARException e) {
System.out.println(e.getMessage());
}
}
}
I'm receiving this error:
ERROR (91): RPC call failed; 127.0.0.1:8080 can not receive ONC/RPC data
How can I fix that? I need to set the instance, like 127.0.0.1/arsys. My Remedy instance is arsys.
I can authenticate using the browser: http://127.0.0.1:8080/arsys
Thanks in advance.
is your midtier on the same server as your AR server?
if not, then You need to set the IP of your AR server instead.
Since you have mentioned that you are able to authenticate using http://127.0.0.1:8080/arsys via browser, it means that 8080 is being used by web server and AR Server can't use the same. Please provide your port number(where your AR Server is listening) in setPort(). Also try to make sure that your hostname/ip address is reachable from the machine where you are executing your program.
The setServer parameter expects the name of the ARS server, not the IP address. Here is the matching constructor signature:
ARServerUser(java.lang.String user, java.lang.String password, java.lang.String locale, java.lang.String serverName, int serverPort)
References
com.remedy.arsys.api.ARServerUser
How to authenticate in Remedy using Java

Locally working web-app throws VerifyError on GAE

my web-app based on GWT uses scala-compiler.jar (2.10.3) on its server-side to provide on the fly compiling and executing of Scala code which a user inputs in his/her browser.
It's working fine locally uder GAE SDK 1.8.4 -- when I call service method and pass some trivial script it compiles, executes and logs the resulting string "Hello, Adeal!":
final Object o = AdalModuleEval.eval("class C { override def toString = \"Hello, Adeal!\" }; new C()");
log.warning(o.toString());
But after deploying to Google App Engine server the same code throws me:
exception: java.lang.VerifyError: Bad type on operand stack in method sun.reflect.generics.repository.ClassRepository.getSuperclass()Ljava/lang/reflect/Type; at offset 1
Full stack trace you can see here
It's really disappointing and I'd very appreciate any suggestions about how to resolve this issue.
Thanks in advance,
Alex
You probably solved that or this below is not your case, but for me it was a method catching exceptions like this:
try {
...
} catch (ServiceException | IOException e) {
e.printStackTrace();
}
Once I put a single Exception in every catch everything worked properly

Categories

Resources