I am trying to call a method of a web service using an auto generated stub.
At following line it assigns,
Method threw 'java.lang.LinkageError' exception. Cannot evaluate org.apache.axiom.soap.impl.llom.soap11.SOAP11BodyImpl.toString()
as the SOAP envelope.
env = toEnvelope(getFactory(_operationClient.getOptions().getSoapVersionURI()),
simpleQueryInput587,
dummyWrappedType,
optimizeContent(new javax.xml.namespace.QName("http://docs.oasis-open.org/ns/bpel4people/ws-humantask/api/200803",
"simpleQuery")));
what is the reason for this?
This was caused since same package has been exported by two jars.
Related
Can anyone please help me understand the below piece of code? What does the second line doing? I am unable to break down that code. I am learning how to write webservices using JAX-RS and happened to come by this code.
String responsedata =
"{\"custId\":"+list.get(0)+",\"accountId\":"list.get(1)+"}";
return Response.status(201).entity(responsedata).build();
You're creating a Response object using fluent interface. Response.status() sets the status code and returns a Response.ResponseBuilder and sets the response entity body Response.entity() and also returns the same builder. Whenever you have a builder, you are using the Builder pattern. When you're done building the object, you call build() which will return the final object. In this case, it returns the Response object.
I need to get messagesource to get access message.properties file in simple groovy class(Exception class) so that i am using Holders.getGrailsApplication(). My problem is Holders.getGrailsApplication() is getting null when i execute unit test case.It works fine if i deploy it in web server.
Variable :-
static def grailsApplicationCntx=Holders.getGrailsApplication().getMainContext().getBean(‘messageSource’)
Error:-
`Failure: testActivateService_Case1(com.xyz.ActivationServiceTests)
| java.lang.ExceptionInInitializerError
at java.lang.Class.forName(Class.java:186)
at com.xyz.DatabaseService.addBankUser(DatabaseService.groovy:11)
at com.xyz.RegisterService.register(RegisterService.groovy:39)
at com.xyz.ActivationServiceTests.setUp(ActivationServiceTests.groovy:60)
Caused by: java.lang.NullPointerException: Cannot invoke method getMainContext() on null object
at com.xyz.exception.Exception.(Exception.groovy:55)
… 4 more
I think no need to inject messageSource. It is already available there.Just use
messageSource.addMessage("foo.bar", request.locale, "My Message")
I'm trying to call a WebService from Grails using CXF plugin version: 1.1.3
Have generated Java classes for the WSDL via the command:
WsdlToJava "--wsdl=src/java/wsdls/jdeRteListenerService.wsdl --mark -p mypackage.pms.OsrJdeRteSvc -client -impl"
When I went to run the webservice call I would get:
Class not known to this context for class: mypackage.pms.OsrJdeRteSvc.ListAllEventsRequest.
Following this stackoverflow article: JAXB Exception: Class not known to this context
I added to the Port class:
#XmlSeeAlso({mypackage.pms.OsrJdeRteSvc.impl.ObjectFactory.class, mypackage.pms.OsrJdeRteSvc.ListAllEventsRequest.class})
Now I get the error:
Unable to find a JAXB implementation to delegate.
JAXB Source has a comment:
if(!modified) {
// if the class list doesn't contain any of our classes,
// this ContextFactory shouldn't have been called in the first place
// if we simply continue, we'll just end up with the infinite recursion.
// the only case that I can think of where this could happen is
// when the user puts additional classes into the JAXB-generated
// package and pass them to JAXBContext.newInstance().
// Under normal use, this shouldn't happen.
// anyway, bail out now.
// if you hit this problem and wondering how to get around the problem,
// subscribe and send a note to users#jaxb.dev.java.net (http://jaxb.dev.java.net/)
throw new JAXBException("Unable to find a JAXB implementation to delegate");
}
https://svn.java.net/svn/jaxb~version2/tags/jaxb-2_2_3u1/xjc/src/com/sun/tools/xjc/runtime/JAXBContextFactory.java
I've subscribed to the list but not yet been approved.
Anyway, why am I getting: Unable to find JAXB implementation to delegate?
After some serious debugging I have found I can't call to get a session object in Magento when running a test with EcomDev_PHPUnit module
any singleton/model call i.e. Mage::getSingleton('admin/session') or Mage::getModel('customer/session') eventually throws an exception from EcomDev_PHPUnit_Controller_Request_Http::getHttpHost() saying Cannot run controller test, because the host is not set for base url. which is caused because the $_SERVER['HTTP_HOST'] index is not set
Is there something in the configuration that I could be missing to cause this?
It is a problem related to Magento session initialization that is internal core part of Magento. In order to get rid of this error is to use a mock object, that does not use standard Magento session initialization process, since it uses core php session.
The replacement of session object with mock can be done by using the following code if you've extended your test case from one of the EcomDev_PHPUnit_Test_Case classes.
$sessionMock = $this->getModelMockBuilder('admin/session')
->disableOriginalConstructor() // This one removes session_start and other methods usage
->setMethods(null) // Enables original methods usage, because by default it overrides all methods
->getMock();
$this->replaceByMock('singleton', 'admin/session', $sessionMock);
You can set host in phpunit.xml
<phpunit ....>
...
<php>
<server name='HTTP_HOST' value='http://local.mysite.com' />
</php>
</phpunit>
I've been having problems to access to my EJB services from a standalone client i've developed on grails 2.0.3. The EJB services are deployed on a glassfish server (Java). I tested this code on a netbeans tester class to access the EJBs:
Properties p = new Properties();
p.put("java.naming.factory.initial", "com.sun.enterprise.naming.SerialInitContextFactory");
p.setProperty("java.naming.factory.url.pkgs", "com.sun.enterprise.naming");
p.setProperty("java.naming.factory.state", "com.sun.corba.ee.impl.presentation.rmi.JNDIStateFactoryImpl");
p.setProperty("org.omg.CORBA.ORBInitialHost", INTEGRATION_IP);
p.setProperty("org.omg.CORBA.ORBInitialPort", CORBA_PORT);
ctx = new InitialContext(p);
try {
this.admAuth = (AdmAuthenticationRemote) this.ctx.lookup(Tester.AUTHENTICATION_SERVICE_JNDI);
}catch(Exception e){
...
}
This Tester.AUTHENTICATION_SERVICE_JNDI is a variable tha contains the path to the deployed service, in this case something like "java:global/..." that represents the address to the service that is being requested. This way of accessing the services works perfectly from the tester, but when i try to do the same from grails doesn't works. I am able to create the context the same way, but when i invoke the ctx.lookup() call i get an exception:
Message: Lookup failed for 'java:global/...' in SerialContext[myEnv={java.naming.factory.initial=com.sun.enterprise.naming.SerialInitContextFactory,
java.naming.factory.state=com.sun.corba.ee.impl.presentation.rmi.JNDIStateFactoryImpl, java.naming.factory.url.pkgs=com.sun.enterprise.naming}
Cause: javax.naming.NamingException: Unable to acquire SerialContextProvider for SerialContext[myEnv={java.naming.factory.initial=com.sun.enterprise.naming.SerialInitContextFactory,
java.naming.factory.state=com.sun.corba.ee.impl.presentation.rmi.JNDIStateFactoryImpl, java.naming.factory.url.pkgs=com.sun.enterprise.naming}
[Root exception is java.lang.RuntimeException: Orb initialization erorr]
The main exception is a naming exception, which means that it failed in the ctx.lookup(), but the cause is the orb initialization exception, which has another exception stack:
java.lang.RuntimeException: Orb initialization erorr
Caused by: java.lang.RuntimeException: java.lang.IllegalArgumentException: Can not set long field com.sun.corba.ee.impl.orb.ORBDataParserImpl.waitForResponseTimeout to java.lang.Integer
Caused by: java.lang.IllegalArgumentException: Can not set long field com.sun.corba.ee.impl.orb.ORBDataParserImpl.waitForResponseTimeout to java.lang.Integer
I'm really lost here. I've been having a lot of problems to get this going on grails, I had to get all glassfish jars (libs and modules) so it could make the InitialContext() call, but now i'm not sure if this is still a jar problem or a configuration problem or what it is.
I know that IllegalArgumentException occurs when u try to assign incompatible types in java, but i'm not setting anything like that, so i assume its an internal method initialization.
So the question is why is this exception coming up??
Is there another way to invoke my services from grails that works better??
The error is that you're trying to run your web application using the tomcat plugin in grails (using the command grails run-app). The problem is that when you try to create the InitialContext (com.sun.enterprise.naming.SerialInitContextFactory) groovy gives you an error casting some types if you're using the client libraries for GF 3.1. (I know that this is the problem, but I really don't know the reason for this. Because in theory this should work)
If you generate the .war file and you deploy in an AppServer, you can connect to your EJBs without problems. And if you deploy it on another GF server you don't have to import any of the client jars.
This will work perfect on production, the only problem is that you must compile and deploy your app on the GF server with every little change, and this is a bit annoying in development.
If you want to work outside of GF and using the command "grails run-app", you must modify two of the .jar GF 3.1 on your remote server, where you have the grails application:
1- The jar file $GLASSFISH_HOME/modules/glassfish-corba-omgapi.jar
You should search in the web the class com.sun.corba.ee.spi.orb.ParserImplBase, and modify this part
Field field = getAnyField(name);
field.setAccessible(true);
field.set(ParserImplBase.this, value);
for this
if (name.equalsIgnoreCase("waitForResponseTimeout")) {
Object newValue = new Long(1800000);
Field field = getAnyField(name);
field.setAccessible(true);
field.set(ParserImplBase.this, newValue);
} else {
Field field = getAnyField(name);
field.setAccessible(true);
field.set(ParserImplBase.this, value);
}
this should resolve the java.lang.IllegalArgumentException
2- The jar file $GLASSFISH_HOME/modules/glassfish-corba-orb.jar
you must delete the javax.rmi.CORBA.PortableRemoteObjectClass class of this library, because this class have conflicts with one used by the grails plugin
PS:
If you do not want to have the GF client jars in your grails application, you can add to the classpath of your client machine the following libraries
$GLASSFISH_HOME/modules/ejb-container.jar
$GLASSFISH_HOME/modules/ejb.security.jar
$GLASSFISH_HOME/modules/management-api.jar
If you use the grails console with the grails run-app command, must modify the configuration file $GRAILS_HOME/conf/groovy-starter.conf whit this
load $GLASSFISH_HOME/modules/ejb-container.jar
load $GLASSFISH_HOME/modules/ejb.security.jar
load $GLASSFISH_HOME/modules/management-api.jar