I need to call an external webservice from my bundle which is deployed in apache felix container ( I can not use ServiceMix, fuse...)
I added the bundle cxf-dosgi (which can be downloaded from here) and put the following lines in my pom.xml:
<Require-Bundle>cxf-dosgi-ri-singlebundle-distribution</Require-Bundle>
<Import-Package>
javax.jws,
javax.xml.bind,
javax.xml.bind.annotation,
javax.xml.namespace,
javax.xml.ws,
META-INF.cxf,
org.apache.cxf,
org.apache.cxf.binding,
org.apache.cxf.binding.soap,
org.apache.cxf.binding.soap.spring,
org.apache.cxf.bus,
org.apache.cxf.bus.resource,
org.apache.cxf.bus.spring,
org.apache.cxf.buslifecycle,
org.apache.cxf.catalog,
org.apache.cxf.configuration,
org.apache.cxf.configuration.spring,
org.apache.cxf.endpoint,
org.apache.cxf.headers,
org.apache.cxf.management,
org.apache.cxf.phase,
org.apache.cxf.resource,
org.apache.cxf.transport,
org.apache.cxf.transport.http,
org.apache.cxf.transport.http.policy,
org.apache.cxf.transport.http_jetty,
org.apache.cxf.transports.http,
org.apache.cxf.workqueue,
org.apache.cxf.ws.policy.builder.jaxb,
org.apache.cxf.wsdl,
org.apache.cxf.wsdl11,
org.apache.cxf.jaxws.*,
*
</Import-Package>
I use the jaxws way to establish the communication:
QName SERVICE_NAME = new QName("http://test.com/", "MockImplService");
Service service = Service.create(new URL(endpointAddress + "?wsdl"), SERVICE_NAME);
mockService= service.getPort(IMock.class);
When I run the example I have the following exception:
Caused by: javax.xml.ws.spi.FactoryFinder$ConfigurationError: Provider org.apache.axis2.jaxws.spi.Provider not found
at javax.xml.ws.spi.FactoryFinder$2.run(FactoryFinder.java:138)
at javax.xml.ws.spi.FactoryFinder.doPrivileged(FactoryFinder.java:282)
at javax.xml.ws.spi.FactoryFinder.newInstance(FactoryFinder.java:125)
at javax.xml.ws.spi.FactoryFinder.access$200(FactoryFinder.java:42)
at javax.xml.ws.spi.FactoryFinder$3.run(FactoryFinder.java:273)
at javax.xml.ws.spi.FactoryFinder.doPrivileged(FactoryFinder.java:282)
at javax.xml.ws.spi.FactoryFinder.find(FactoryFinder.java:168)
at javax.xml.ws.spi.Provider.provider(Provider.java:39)
at javax.xml.ws.Service.<init>(Service.java:36)
at javax.xml.ws.Service.create(Service.java:116)
any idea please ?
Apache DOSGi is designed for exposing services as webservices, not for calling other webservices. Though, it probably contains some api to call other webservices.
Somehow the axis jaxws implementation is used. You probably have a axis2-jaxws-xxx.jar on your classpath. Try to remove it. The JRA jaxws will be used instead (which should be fine for axis and better for cxf).
Related
I currently have an Apache Tomcat (9.0.43) server running on jre1.8.0_261. For various reasons, I'm trying to run the same code on jre-9.0.4. When I try this, I get the following error in Apache's localhost.date.log file:
java.lang.NoClassDefFoundError: Could not initialize class customName.customConfig.User
where customName and customConfig are parts of a user-defined class (which we wrote) that has been successfully running on Tomcat for years, and continues to work just fine on jre1.8. It's only when I try to run with jre-9.0.4 that I get the error.
Is there a way to get jre-9 to 'recognize' the class, for lack of a better word? I know where to find its .class file (and so does jre-1.8).
I have a spring boot application bundled as war file , and able to push to App Engine
But I am getting problems starting app (I suspect there could be an issue with DB too...but couldnt remember where I saw...a nightmare)
java.lang.RuntimeException: java.lang.IllegalStateException: Logback
configuration error detected: ERROR in
ch.qos.logback.core.rolling.RollingFileAppender[FILE] - Failed to
create parent directories for
[/base/data/home/apps/e~pemy/20210716t001812.436581063072799646/logs/pynew.log]
ERROR in ch.qos.logback.core.rolling.RollingFileAppender[FILE] -
openFile(logs/pynew.log,true) call failed.
java.io.FileNotFoundException: logs/pynew.log (No such file or
directory)
I am using the below properties in my application props
> logging.file.path=logs
> logging.file.name=${logging.file.path}/pynew.log
I am finding it very hard to include google specific dependencies and properties , and making a mess of my project...created app.yaml, web-inf>> appengine-web xml, logging.properties (not sure why but added as told in a tutorial)
Question: How can I create parent directory or link to cloud storage folder etc?
I also want to specify a profile and I see I can do it in yaml file. Is this used only
env_variables:
JAVA_USER_OPTS: '-Dspring.profiles.active=prod'
But I would like to know how to connect to Cloud SQL
spring.datasource.url=jdbc:mysql:///mydb?cloudSqlInstance=myapp:europe-west2:dBinstancename&socketFactory=com.google.cloud.sql.mysql.SocketFactory
spring.datasource.username=${dbuser}
spring.datasource.password=ENC(${dbencpwd})
spring.cloud.gcp.sql.database-name=mydb
spring.cloud.gcp.sql.instance-connection-name=myapp:europe-west2:dBinstancename
It is so confusing that I keep forgetting which connection needs password and which wont. and keep breaking my local
Question
Assuming that I need to supply credentials, How can I supply - ${dbuser}
I used the default spring logger with logback-spring.xml for all my development, and this is not working on AppEngine
So I followed https://cloud.google.com/logging/docs/setup/java
and added logback.xml and the dependency
implementation 'com.google.cloud:google-cloud-logging-logback:0.121.3-alpha'
I want to validate xml against schema - using SpringBoot 2 and camel 3.
On localhost this works:
.to("validator:file:src/main/resources/D.xsd")
But when uploaded to server on tomcat machine with context for example D - i get an error:
Caused by: java.io.FileNotFoundException: src/main/resources/D.xsd (No such file or directory)
I think that i need to change the path to use classpath - but i am not sure how to make it work ?
What i tried:
.to("validator:file:classpath:/src/main/resources/D.xsd")
.to("validator:file:resource:classpath:src/main/resources/D.xsd")
.to("validator:file:resource:classpath:/src/main/resources/D.xsd")
But it does not work.
In one of my applications (but with SpringBoot 1.5 and Camel 2.x) this works fine
.to("validator:classpath:folder/filename.xsd")
to validate against filename.xsd that is located in src/main/resources/folder
I've managed to fix it with:
.to("validator:D.xsd")
I'm using arquilian to test a JMS query. I've seen that i'm able to deploy a descriptor using the Descriptors class, like below:
#Deployment
public static Descriptor create() {
return Descriptors.create(HornetQDescriptor.class);
}
Ok, but I can't find the HornetQDescriptor class anywhere! I'm using Arquillian 1.1.7.Final, with ShrinkWrap Desriptors 2.0.0-Alpha-7 and Maven. Any help?
Ok, I think I found a trick...
I added a hornetq-jms.xml to src/test/resources and to my arquillian jar and it worked fine. It was something like that:
#Deployment
public static JavaArchive createTestArchive() {
return ShrinkWrap.create(JavaArchive.class, "test.jar")
.addAsManifestResource("hornetq-jms.xml")
.addAsManifestResource(EmptyAsset.INSTANCE, ArchivePaths.create("beans.xml"));
}
and one default hornetq xml:
<messaging-deployment xmlns="urn:jboss:messaging-deployment:1.0">
<hornetq-server>
<jms-destinations>
<jms-queue name="myQueue">
<entry name="/queue/myQueue"/>
</jms-queue>
</jms-destinations>
</hornetq-server>
</messaging-deployment>
And it worked fine. Not the way I expected doing, but it worked anyway =)
What kind of server u used , embedded or managed .
I am tryin to use hornetq-jms.xml but the embedded server I use is throwing exception about the xmlns="urn:jboss:messaging-deployment:1.0" .
About the HornetQDescriptor there are examples from 2011's versio of the descriptor api : Check this git hub location
As far the Api is changed for example : Descriptor Api
org.jboss.shrinkwrap.descriptors » shrinkwrap-descriptors-api-javaee » 2.0.0-alpha-9
The api is totally changed so the code above is not usable am afraid .
So can u give me more details what server u used and if it is embedded how u suceed to deploy the hornet - jms . xml
I would like to be able to package my jpa-ejb-web project as a standalone application, by using Glassfish embedded API.
To use the JPA layer, I need to deploy the sun-resource.xml configuration, which should be possible with the asadmin command add-resources path\to\sun-resources.xml. I've this code to do it:
String command = "add-resources";
ParameterMap params = new ParameterMap();
params.add("", "...\sun-resources.xml" );
CommandRunner runner = server.getHabitat().getComponent(CommandRunner.class);
ActionReport report = server.getHabitat().getComponent(ActionReport.class);
runner.getCommandInvocation(command, report).parameters(params).execute();
but Glassfish refuses it with:
15-Jul-2010 16:34:12 org.glassfish.admin.cli.resources.AddResources execute
SEVERE: Something went wrong in add-resources
java.lang.Exception: ...\gfembed6930201441546233570tmp\lib\dtds\sun-resources_1_4.dtd (The system cannot find the path specified)
at org.glassfish.admin.cli.resources.ResourcesXMLParser.initProperties(ResourcesXMLParser.java:163)
at org.glassfish.admin.cli.resources.ResourcesXMLParser.<init>(ResourcesXMLParser.java:109)
at org.glassfish.admin.cli.resources.ResourcesManager.createResources(ResourcesManager.java:67)
at org.glassfish.admin.cli.resources.AddResources.execute(AddResources.java:106)
at com.sun.enterprise.v3.admin.CommandRunnerImpl$1.execute(CommandRunnerImpl.java:305)
at com.sun.enterprise.v3.admin.CommandRunnerImpl.doCommand(CommandRunnerImpl.java:320)
at com.sun.enterprise.v3.admin.CommandRunnerImpl.doCommand(CommandRunnerImpl.java:1176)
at com.sun.enterprise.v3.admin.CommandRunnerImpl.access$900(CommandRunnerImpl.java:83)
at com.sun.enterprise.v3.admin.CommandRunnerImpl$ExecutionContext.execute(CommandRunnerImpl.java:1235)
at com.sun.enterprise.v3.admin.CommandRunnerImpl$ExecutionContext.execute(CommandRunnerImpl.java:1224)
at javaapplication4.Main.main(Main.java:55)
and indeed, there is no lib directory on the indicated path ...
is there something wrong in my code? (I use glassfish-embedded-all-3.0.1.jar)
Thanks
I solved it by specifying an Embedded File System for the embedded Glassfish, and prepopulated the /path/to/my/glassfish/lib/dtds folder with the files which were missing.
EmbeddedFileSystem.Builder efsb = new EmbeddedFileSystem.Builder();
efsb.autoDelete(false);
efsb.installRoot(new File("/path/to/my/glassfish"), true);
EmbeddedFileSystem efs = efsb.build();
Server.Builder builder = new Server.Builder("test");
builder.embeddedFileSystem(efs);
builder.logger(true);
Server server = builder.build();
server.addContainer(ContainerBuilder.Type.all);
server.start();
and asking Glassfish not to delete the folder at the end of the execution.
I'm not sure this is possible, Running asadmin Commands Using the Sun GlassFish Embedded Server API doesn't mention such a use case (passing a sun-resources.xml).
But I would use a preconfigured domain.xml instead of trying to deploy a sun-resource.xml file, the result should be similar. From the Sun GlassFish Enterprise Server v3 Embedded Server Guide:
Using an Existing domain.xml File
Using an existing domain.xml file
avoids the need to configure embedded
Enterprise Server programmatically in
your application. Your application
obtains domain configuration data from
an existing domain.xml file. You can
create this file by using the
administrative interfaces of an
installation of nonembedded Enterprise
Server. To specify an existing
domain.xml file, invoke the
installRoot, instanceRoot, or
configurationFile method of the
EmbeddedFileSystem.Builder class or
a combination of these methods.
The documentation provides code samples showing how to do this (should be pretty straightforward).