I have been using Apache CXF 2.7.0 for quite a while now, but recently I had to restructure my project in Eclipse. After I did that, for some reason, I cannot add a "WSAddressingFeature" Feature to the endpoint.
What am I missing??
endpoint.getFeatures().add(new org.apache.cxf.ws.addressing.WSAddressingFeature());
Eclipse is reporting that:
"The method add(Feature) in the type List<Feature> is not applicable for the arguments (WSAddressingFeature)"
This is my full implementation:
String url = "http://localhost:" + m_Port + "/infoburst/handler";
Object implementor = new HandlerImpl();
org.apache.cxf.jaxws.EndpointImpl endpoint = new org.apache.cxf.jaxws.EndpointImpl(implementor);
endpoint.getFeatures().add(new org.apache.cxf.ws.addressing.WSAddressingFeature());
endpoint.publish(url);
org.apache.cxf.endpoint.Server server = endpoint.getServer();
org.apache.cxf.jaxws.JaxWsServerFactoryBean serverFB = endpoint.getServerFactory();
If I remove the line of code that adds the feature, the following error occurs:
Exception in thread "main" java.lang.NoSuchMethodError: org.apache.cxf.common.util.ReflectionUtil.getDeclaredMethod(Ljava/lang/Class;Ljava/lang/String;[Ljava/lang/Class;)Ljava/lang/reflect/Method;
at org.apache.cxf.jaxws.support.JaxWsServiceFactoryBean.bindOperation(JaxWsServiceFactoryBean.java:276)
at org.apache.cxf.service.factory.ReflectionServiceFactoryBean.createOperation(ReflectionServiceFactoryBean.java:1045)
at org.apache.cxf.jaxws.support.JaxWsServiceFactoryBean.createOperation(JaxWsServiceFactoryBean.java:642)
at org.apache.cxf.service.factory.ReflectionServiceFactoryBean.createInterface(ReflectionServiceFactoryBean.java:990)
at org.apache.cxf.service.factory.ReflectionServiceFactoryBean.buildServiceFromClass(ReflectionServiceFactoryBean.java:481)
at org.apache.cxf.jaxws.support.JaxWsServiceFactoryBean.buildServiceFromClass(JaxWsServiceFactoryBean.java:704)
at org.apache.cxf.service.factory.ReflectionServiceFactoryBean.initializeServiceModel(ReflectionServiceFactoryBean.java:550)
at org.apache.cxf.service.factory.ReflectionServiceFactoryBean.create(ReflectionServiceFactoryBean.java:265)
at org.apache.cxf.jaxws.support.JaxWsServiceFactoryBean.create(JaxWsServiceFactoryBean.java:215)
at org.apache.cxf.frontend.AbstractWSDLBasedEndpointFactory.createEndpoint(AbstractWSDLBasedEndpointFactory.java:102)
at org.apache.cxf.frontend.ServerFactoryBean.create(ServerFactoryBean.java:159)
at org.apache.cxf.jaxws.JaxWsServerFactoryBean.create(JaxWsServerFactoryBean.java:211)
at org.apache.cxf.jaxws.EndpointImpl.getServer(EndpointImpl.java:456)
at org.apache.cxf.jaxws.EndpointImpl.doPublish(EndpointImpl.java:334)
at org.apache.cxf.jaxws.EndpointImpl.publish(EndpointImpl.java:251)
at org.apache.cxf.jaxws.spi.ProviderImpl.createAndPublishEndpoint(ProviderImpl.java:155)
at javax.xml.ws.Endpoint.publish(Unknown Source)
at com.infosol.infoburst.XI4Service.HandlerService.publish(HandlerService.java:106)
at com.infosol.infoburst.XI4Service.HandlerService.main(HandlerService.java:42)
This is why I really don't enjoy working in the Java environment...
To fix the ""The method add(Feature) in the type List is not applicable for the arguments (WSAddressingFeature)" error:
Go into "Configure Build Path"
Go to "Order and Export"
Move the "cfx-2.7.0.jar" file to a higher priority, this may take a little trial and error.
Once the CFX file is moved up in priority, the error will go away.
Related
I'm using the Groovy Spreadsheet Builder within one of my Grails projects to export some data as Excel file.
Everything works great until I create a runnable jar (using gradle assemble) and use this.
I'm using the builder within a service like this:
class ExcelService {
...
void export(OutputStream outputStream) {
...
PoiSpreadsheetBuilder.create(outputStream).build {
apply ExcelStylesheet
...
}
}
...
}
When I try to export my data from the app started using the generated jar I will get the following MissingMethodException:
groovy.lang.MissingMethodException: No signature of method: my.package.ExcelService.apply() is applicable for argument types: (java.lang.Class)
The (Java) interface of SpreadsheetBuilder looks like this:
public interface SpreadsheetBuilder {
void build(#DelegatesTo(strategy = Closure.DELEGATE_FIRST, value = WorkbookDefinition.class) #ClosureParams(value = FromString.class, options = "builders.dsl.spreadsheet.builder.api.WorkbookDefinition") Configurer<WorkbookDefinition> workbookDefinition);
}
While debugging the execution of the code and the jar I found the difference while stepping through invokeMethod() of ClosureMetaClass.
When closure.getResolveStrategy(); in the working version is called Closure.DELEGATE_FIRST will be returned. Debugging the jar, the result will be 0 so that the MissingMethodException will be thrown later due to the wrong resolve strategy.
For now I have no idea how to solve this problem.
What is/could be the reason for this behavior?
What can I do to solve this issue?
I'm using Grails 3.3.8 with Java OpenJDK 1.8.0_192.
If you don't need to support JDK 7, you could upgrade to Groovy Spreadsheet Builder 2.0.0.RC1 which is only JDK 8 compatible but appears to solve the problem.
#ClosureParams and #DelegatesTo are applicable to parameters of type groovy.lang.Closure. In this case, you have applied it to Configurer<WorkbookDefinition>.
I´m using Krextor to convert XML to RDF. It runs fine from the command line.
I try to run it from Java (Eclipse) using this code.
private static void XMLToRDF() throws KrextorException, ValidityException, ParsingException, IOException, XSLException{
Element root = new Element("person");
Attribute friend = new Attribute("friends", "http://van-houten.name/milhouse");
root.addAttribute(friend);
Element name = new Element("name");
name.appendChild("Bart Simpson");
root.appendChild(name);
nu.xom.Document inputDocument = new nu.xom.Document(root);
System.out.println(inputDocument.toXML());
Element root1 = inputDocument.getRootElement();
System.out.println(root1);
Krextor k = new Krextor();
nu.xom.Document outputDocument = k.extract("socialnetwork","turtle",inputDocument);
System.out.println(outputDocument.toString());
}
I have the following problem problem
Exception in thread "main" java.lang.NoClassDefFoundError: net/sf/saxon/CollectionURIResolver
Caused by: java.lang.ClassNotFoundException: net.sf.saxon.CollectionURIResolver
I have included Saxon9he in the classpath, and I have also added manually as a library in the project but the error is the same.
I am the main developer of Krextor. And, #Michael Kay, actually a colleague of Grangel, so I will resolve the concrete problem with him locally.
So indeed the last Saxon version with which I did serious testing was 9.1; after that I haven't used Krextor integrated into Java but mainly used Krextor from the command line.
#Grangel, could you please file an issue for Krextor, and then we can work on fixing it together.
Indeed, #Michael Kay, for a while I had been including more recent Saxon versions with Krextor and updated the command line wrapper to use them (such as to add different JARs to the classpath), but I have not necessarily updated the Java wrapper code.
I need to find a way to change the settings of proxy on the IE 9.
I know a way directly in the reg., but ie9 doesn't refresh after I set them.
I tried to use another solution with jna:
Invoke WinInet Functions Used Java + JNA
In my case I use only:
System.out.println("Set refreshed...");
if (!WinInet.INSTANCE.InternetSetOption(
hInternet, WinInet.INTERNET_OPTION_REFRESH, (Pointer) null, len)) {
System.out.println("InternetSetOption failed!:"
+ Kernel32.INSTANCE.GetLastError());
but I get this error:
Set refreshed...
Exception in thread "AWT-EventQueue-0" java.lang.NoClassDefFoundError:
com/sun/jna/platform/win32/WinDef$DWORD
I downloaded the lib jars from here:
http://java.net/projects/jna/downloads/directory/3.3.0
Thank you.
makesure you have platform-3.4.0.jar and jna-3.4.0.jar in your classpath
I have a code which works correctly as expected in my command line java tool.
The same code when I added to eclipse does throw some error:
Exception in thread "main" java.lang.Error: Unresolved compilation problem:
Cannot cast from Object to long
On the line :
long statusId = (long)json.get("status_id");
However with javac and java command I run the program with successful output.
WTH eclipse is behaving this way! And this is my first eclipse program, kindly help me out.
Edit:
Code :
public InitOrderResponse connect()
{
Authentication auth = new Authentication();
String response = auth.httpBasicAuth(this.constructUrl(),this.key);
JSONObject json = (JSONObject) JSONValue.parse(response);
String merchantId = (String)json.get("merchant_id");
long statusId = (long)json.get("status_id");
String status = (String)json.get("status");
String orderId = (String)json.get("order_id");
initOrderResponse = new InitOrderResponse();
initOrderResponse.setStatus(status);
initOrderResponse.setOrderId(orderId);
initOrderResponse.setStatusId(statusId);
initOrderResponse.setMerchantId(merchantId);
return initOrderResponse;
}
Your eclipse has error/warnings constraints set to give error for some condition, that is not imposed by Java compiler by default.To change these rules, right click on the project, click on properties. Under 'Java Compiler' menu, go to 'errors/warnings'. There you can set constraints for compiler to give errors/warnings.
The problem was with the Jdk versions. When I changed the jdk to point towards the Sun's JDK. Everything works as expected.
I'm trying to execute a simple HelloWorld rule within an OSGi application. During parsing and compiling however, the following exception occurs:
java.lang.NullPointerException
at org.drools.rule.builder.RuleBuilder.build(RuleBuilder.java:47)
at org.drools.compiler.PackageBuilder.addRule(PackageBuilder.java:446)
at org.drools.compiler.PackageBuilder.addPackage(PackageBuilder.java:304)
at org.drools.compiler.PackageBuilder.addPackageFromDrl(PackageBuilder.java:167)
The DRL file is found by the application, since introducing syntax errors results in a failed compilation warning. I guess I'm overlooking something trivial, but haven't found it yet...
I'm using Drools 4.0.7, since this one was available on the Springsource Enterprise Bundle Repository. Here are my application code and drl:
//read in the source
Reader source = new InputStreamReader( getClass().getResourceAsStream( "hello.drl" ) );
PackageBuilder builder = new PackageBuilder();
//this wil parse and compile in one step
builder.addPackageFromDrl( source );
// Check the builder for errors
if ( builder.hasErrors() ) {
System.out.println( builder.getErrors().toString() );
throw new RuntimeException( "Unable to compile \"hello.drl\".");
}
//get the compiled package (which is serializable)
org.drools.rule.Package pkg = builder.getPackage();
//add the package to a rulebase (deploy the rule package).
RuleBase ruleBase = RuleBaseFactory.newRuleBase();
ruleBase.addPackage( pkg );
StatefulSession session = ruleBase.newStatefulSession();
session.fireAllRules();
#created on: May 1, 2011
package test
rule "A stand alone rule"
when
eval(true)
then
System.out.println("hello world");
end
As always, help is highly appreciated.
KR,
Niels
EDIT: During debugging I noticed that the internal builder object within the PackageBuilder was null, as were the package and packagedescription. I got around the original problem by adding this description manually:
PackageBuilder builder = new PackageBuilder();
PackageDescr packageDescr = new PackageDescr("be.ugent.intec.doctr.processor.job.fever");
builder.addPackage(packageDescr);
//this will parse and compile in one step
builder.addPackageFromDrl( source );
My rule was edited to the following form:
package be.ugent.intec.doctr.processor.job.fever
rule "hello"
when
eval( true )
then
System.out.println("hello there");
end
This however results in a compile failure:
BR.recoverFromMismatchedToken
[1,0]: unknown:1:0 mismatched token: [#0,0:6='println',<7>,1:0];
java.lang.RuntimeException: Unable to compile "hello.drl".
at be.ugent.intec.doctr.processor.job.fever.FeverJob.execute(FeverJob.java:45)
at org.quartz.core.JobRunShell.run(JobRunShell.java:202)
at org.quartz.simpl.SimpleThreadPool$WorkerThread.run(SimpleThreadPool.java:525)
When removing the package line from the rule, then my example goes all the way through, without printing anything however. Am I again overlooking anything? I guess this is related to an issue within the drl itself, considering everything stands or falls with the declaration of the package. Just to be clear, the drl is loaded in a class contained in the package be.ugent.intec.doctr.processor.job.fever.
Thx!
A NullPointerException shouldn't happen during compilation: either you get a clear compilation error during parsing (which includes line number) or it works. Drools 4.0.7 is old. This is probably already fixed in a newer version of drools. If it isn't, raise a JIRA issue.
Try a more up-to-date version of drools, preferably even a 5.2 version (5.2.0.CR1 will be out later today or tomorrow), which uses the new, better parser.