jaxb bindings : package for namespace (scd) not working - jaxb

I am trying to map a package name to a namespace
As per the doc : https://github.com/highsource/maven-jaxb2-plugin/wiki/Configure-Target-Packages-in-Binding-Files
<jaxb:bindings xmlns:tns="http://www.myexample.com/my-service/request" scd="x-schema::tns">
<jaxb:schemaBindings >
<jaxb:package name="com.request" />
</jaxb:schemaBindings>
</jaxb:bindings>
It seems to be ignored.
see full sample : https://github.com/deslauriersp/jaxb-bindings-not-working

the problem is in XJC itsetf
the bindings are not working when using -wsdl option (which is experimental and officially not supported)
My solution was to includes all XSD but not the WSDL itself

Related

Property "Value" is already defined. How resolve from ANT

I am using ANT build.xml to generate java proxy class. There i am getting below error.
"[wsimport] [ERROR] Property "Value" is already defined. Use <jaxb:property> to resolve this conflict."
How to perform external binding through ANT build.xml.
Use xjc ANT task
write a bindings (.xjb) to define the appropriate jaxb:property
add -b argument to xjc execution task in ANT.
<arg value="-b"/>
<arg value="bindings.xjb"/>

Episode file not being generated

I am building a project using the maven-jaxb2-plugin
<groupId>org.jvnet.jaxb2.maven2</groupId>
<artifactId>maven-jaxb2-plugin</artifactId>
I set the episode parameter
<episode>true</episode>
However I see that no .episode file is being generated. I need this file so that this project can be used as an episode in another dependent project.
In the maven build logs I do see these logs which indicate that the episode & episodeFile parameter supported by xjc are not supported by the plugin:
[WARNING] Unknown plugin option: -episode
[WARNING] Unknown plugin option: C:\projecdir\src\main\generated-sources\META-INF\sun-jaxb.episode
Is this a bug in the plugin? Also is there any known workaround for this.
Update: Something strange happens when useDependenciesAsEpisodes is not false
useDependenciesAsEpisodes = true
When this was true it shows the warning above. This build works but no episode file is generated.
useDependenciesAsEpisodes = false
When I set this to false the episode file is generated.
However I had some additional arguments passed for a plugin which break the build.
<args>
<arg>-typeId=7000</arg>
...
</args>
Error:
Caused by: com.sun.tools.xjc.BadCommandLineException: unrecognized parameter -typeId=7000
at com.sun.tools.xjc.Options.parseArguments(Options.java:817)
at org.jvnet.mjiip.v_2.OptionsFactory.createOptions(OptionsFactory.java:91)
... 24 more
I have to remove the additional args for this to work. However I need those arguments for some jaxb plugins (like shown here) used along with maven-jaxb2-plugin
<configuration>
<extension>true</extension>
<args>
<arg>-XtoString</arg>
<arg>-Xequals</arg>
<arg>-XhashCode</arg>
<arg>-Xcopyable</arg>
</args>
<plugins>
<plugin>
<groupId>org.jvnet.jaxb2_commons</groupId>
<artifactId>jaxb2-basics</artifactId>
<version><!-- version --></version>
</plugin>
</plugins>
</configuration>
Author of the maven-jaxb2-plugin and jaxb2-basics here.
Episode generation is tested quite thoroughly on each release, so I'm pretty sure it works.
useDependenciesAsEpisodes just adds all your dependency JARs as "episode" JARs, this should not influence episode generation.
-typeId=7000 is a bit suspicious, which XJC plugin processes this command? If none, this may potentially interfere with -episode, so this is where I'd look first.
What really helps is to see the mvn clean install -e -X log. It should lok the arguments finally passed to XJC, so there you could spot irregularities.
If nothing helps, put a minimal reproducing test project together and commint/send me a PR for this project in https://github.com/highsource/maven-jaxb2-plugin-support ex. under e/episode-file-not-being-generated.

Unresolved assembly reference with sandcastle

I am trying to generate documentation with sandcastle help file builder. While building the project in the sandcastle i am getting the following error.
MRefBuilder : error : Unresolved assembly reference: Microsoft.Owin (Microsoft.Owin, Version=2.1.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35) required by Microsoft.AspNet.Identity.Owin [C:\Users\inkosah\Documents\Help\Working\GenerateRefInfo.proj]
Last step completed in 00:01:19.4610
Can anybody help me to resolve this issue? I also tried adding it separately to project references in the sandcastle but no help.
Solution 1 : Add missing references to a dummy project.
Create 'dummyProject' (ie class library)
In Visual Studio - Package Manager Console
Install-Package Microsoft.Owin -Version 2.1.0.0 -ProjectName dummyProject
Install-Package Microsoft.Owin.Security.OAuth -version 2.1.0.0 -ProjectName dummyProject
In Sandcastle Help Fil Builder - Project Explore, add two references
Microsoft.aspNet.identity.Owin (dll found in ..\packages\Microsoft.AspNet.Identity.Owin.2.2.0\lib\net45)
Microsoft.Owin (dll found in ..\packages\Microsoft.Owin.2.1.0\lib\net45\Microsoft.Owin.dll)
It looks like MRefBuilder found that Microsoft.AspNet.Identity.Owin relies on Microsoft.Owin (== v 2.1.0) and not Microsoft.Owin (>= 2.1.0).
The main project is still using Microsoft.Owin 3.0.1.0
Solution 2 : Ignore unresolved references
In Documentation (or SHFB) Project Properties / Plug-Ins :
Add "Assembly Binding Redirection" in "Plugs-Ins in This Project"
configure it to "ignore if Unresolved" "Microsoft.Owin" and "Microsoft.Owin.Security.OAuth"

Phalanger error in Visual Studio

I have installed Phalanger from http://phalanger.codeplex.com/ and installed Phalanger Tools from the built-in market-place function in my Visual Studio 2012 Ultimate distribution. After doing this, every time I boot start Visual Studio I get a dialog-box with the error:
If I examine ActivityLog.xml I find the following errors (all other elements omitted):
<?xml version="1.0" encoding="utf-16"?>
<?xml-stylesheet type="text/xsl" href="ActivityLog.xsl"?>
<activity>
<entry>
<record>16</record>
<time>2013/10/04 14:43:55.426</time>
<type>Error</type>
<source>VisualStudio</source>
<description>Loading UI library</description>
<guid>{712C84E3-B447-4283-ABF3-D00B161E63FE}</guid>
<hr>800a006f</hr>
<errorinfo>Cannot find the requested resource.</errorinfo>
</entry>
<entry>
<record>63</record>
<time>2013/10/04 14:44:03.569</time>
<type>Error</type>
<source>VisualStudio</source>
<description>SetSite failed for package [PHP.Project.PHPProjectPackage, PHP.VS, Version=1.8.4608.0, Culture=neutral, PublicKeyToken=17116b35d45f8bb8]</description>
<guid>{9DD0D70B-6760-4C96-B1DC-03AAF937D95A}</guid>
<hr>80004003 - E_POINTER</hr>
<errorinfo>Object reference not set to an instance of an object.</errorinfo>
</entry>
<entry>
<record>64</record>
<time>2013/10/04 14:44:03.574</time>
<type>Error</type>
<source>VisualStudio</source>
<description>End package load [PHP.Project.PHPProjectPackage, PHP.VS, Version=1.8.4608.0, Culture=neutral, PublicKeyToken=17116b35d45f8bb8]</description>
<guid>{9DD0D70B-6760-4C96-B1DC-03AAF937D95A}</guid>
<hr>80004003 - E_POINTER</hr>
<errorinfo>Object reference not set to an instance of an object.</errorinfo>
</entry>
</activity>
Does anyone have a take on what I could do to relieve this?
It seams, you have PHP Tools for Visual Studio, not Phalanger Tools. Also it is possible you installed PHP Tools in addition to Phalanger Tools.
Try to uninstall both, and install Phalanger Tools only.

Which JDK's distributions can run `javac -source 1.6 -target 1.5`?

NOTE: Please do not comment on all the perils of cross-compiling. Thank you.
I have a situation where we need to have Java 6 source compiled for a Java 5 JVM (to be sure that JAX-WS usage is correct). Previously we have done this with ant ant script (which apparently can), but after migrating to Maven we have found that it ends up with javac complaining:
$ javac -source 1.6 -target 1.5
javac: source release 1.6 requires target release 1.6
Is there any Java distribution for Linux (Ubuntu 11.10, x86) where the javac can do this?
EDIT: It appears not, as the limitation is in javac which is the same. The solution (which made this need go away) was to change from the default javac compiler to the eclipse compiler in maven-compiler-plugin.
EDIT: I've found that the Eclipse compiler generates byte code for anonymous inner classes that the javadoc utility disagrees with. I am preparing a bug report for this issue.
According to the documentation (Java 5, Java 6), the Oracle SDK should be able to do this when you follow the instructions in the Cross-Compilation Example.
Java 6 should support any version between 1.3 to 1.6 as -target; it doesn't say anything what happens when you use generics and other "compatible" features in the source. The compiler should be able to strip them.
Another culprit in the game might be javac: The compiler might be able to handle this set of arguments but the command line tool might take offense.
In this case, write your own command line using the Java Compiler API. That might allow to pull of some tricks that you can't achieve otherwise.
You can also try the Eclipse compiler (see "Using the batch compiler").
This might fail because of how Java works: Java X code can run on Java Y as long as X <= Y. So while you can easily compile Java 1.4 code for a Java 6 VM, the reverse is not always true.
If everything else fails, write a preprocessor that reads the source and strips unsupported elements (like #Override on interfaces). As long as you compile the code with the annotations once in a while with Java 6, the converted code should be safe as well (unless your code stripper has a bug ...)
This answer is an implementation of what #ThorbjørnRavnAndersen explained in the comments as a solution. Using the example code from here, and fixing a few typos, I was able to come up with an example using Eclipse Compiler.
Calculator.java
package example;
// there needs to be a package to avoid A "#WebService.targetNamespace must be specified on classes with no package"
// when running this
import javax.jws.WebService;
import javax.jws.WebMethod;
import javax.xml.ws.Endpoint;
#WebService
public class Calculator {
#WebMethod
public int add(int a, int b) {
return a+b;
}
public static void main(String[] args){
// create and publish an endpoint
Calculator calculator = new Calculator();
Endpoint endpoint = Endpoint.publish("http://localhost:8080/calculator", calculator);
}
}
pom.xml
<project>
<modelVersion>4.0.0</modelVersion>
<groupId>fi.eis.applications</groupId>
<artifactId>ws-calculator</artifactId>
<version>1.0-SNAPSHOT</version>
<build>
<plugins>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.3</version>
<configuration>
<source>1.6</source>
<target>1.5</target>
<compilerId>eclipse</compilerId>
</configuration>
<dependencies>
<dependency>
<groupId>org.codehaus.plexus</groupId>
<artifactId>plexus-compiler-eclipse</artifactId>
<version>2.6</version>
</dependency>
</dependencies>
</plugin>
</plugins>
</build>
</project>
That you can compile with mvn clean compile and then run with java Calculator on the target/classes/example folder. It will start up a web service on port 8080, which you can test with url http://localhost:8080/calculator?wsdl on your browser.

Resources