newer wsgen cannot find existing WebService annotation - wsgen

We have a working web service using Java 8 that we are trying to upgrade to Java 11.
jaxws-ri\bin\wsgen.bat (version "JAX-WS RI 4.0.0-M4 git-revision#ac6e723") displays the following exception:
Exception in thread "main" com.sun.xml.ws.model.RuntimeModelerException: A WebService annotation is not present on class: com.xxxxxx.security.services.webservice.SecurityServiceImpl
at com.sun.xml.ws.model.RuntimeModeler.buildRuntimeModel(RuntimeModeler.java:234)
at com.sun.xml.ws.db.DatabindingImpl.<init>(DatabindingImpl.java:70)
at com.sun.xml.ws.db.DatabindingProviderImpl.create(DatabindingProviderImpl.java:51)
at com.sun.xml.ws.db.DatabindingProviderImpl.create(DatabindingProviderImpl.java:28)
at com.sun.xml.ws.db.DatabindingFactoryImpl.createRuntime(DatabindingFactoryImpl.java:92)
at com.sun.tools.ws.wscompile.WsgenTool.buildModel(WsgenTool.java:247)
at com.sun.tools.ws.wscompile.WsgenTool.run(WsgenTool.java:102)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.base/java.lang.reflect.Method.invoke(Method.java:566)
at com.sun.tools.ws.Invoker.invoke(Invoker.java:132)
at com.sun.tools.ws.WsGen.main(WsGen.java:29)
Result: 1
However, our SecurityServiceImpl.java class DOES contain the #Webservice annotation, as shown below
import javax.jws.WebService;
#WebService(name="Foundation Security", serviceName="FoundationSecurityWS", portName="FoundationSecurityWSPort")
public class SecurityServiceImpl {
Our ant build script uses the following wsgen.bat arguments:
<arg line="-cp ${wsgen.classpath.string}"/>
<arg line="-d ${build.webservice}/server"/>
<arg line="-s ${build.webservice}/serversource"/>
<arg line="-r ${build.webservice}/resource"/>
<arg line="-wsdl"/>
<arg line="-keep"/>
<arg line="com.xxxxxx.security.services.webservice.SecurityServiceImpl"/>
Thank you in advance for any suggestions

after adding debug logging to JAX-WS com.sun.xml.ws.model.*, the issue seemed to be that "import javax.jws.WebService;" needed to be updated to "import jakarta.jws.WebService;"

Related

How can I run JDK 19 with Structured Concurrency? (ERROR: java.lang.NoClassDefFoundError: jdk/incubator/concurrent/StructuredTaskScope)

Note: this post somehow related with this question; however, the error is different. So I am posting as another question.
I want to try the new Project Loom feature defined in: JEP 428: Structured Concurrency (Incubator)
I created a library project that uses class StructuredTaskScope, which can compile right.
Then I created a test project to demonstrate the use of library project, which can compile right too.
In pom.xml, both projects use:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.10.1</version>
<configuration>
<release>19</release>
<compilerArgs>
<arg>--enable-preview</arg>
<arg>--add-modules=jdk.incubator.concurrent</arg>
</compilerArgs>
</configuration>
</plugin>
However, When i try to run the test project, it returns error below:
C:\me\codes\com.tugalsan\tst\com.tugalsan.tst.thread>java -jar target/com.tugalsan.tst.thread-1.0-SNAPSHOT-jar-with-dependencies.jar --enable-preview --add-modules jdk.incubator.concurrent
Exception in thread "main" java.lang.NoClassDefFoundError: jdk/incubator/concurrent/StructuredTaskScope
at java.base/java.lang.ClassLoader.defineClass1(Native Method)
at java.base/java.lang.ClassLoader.defineClass(ClassLoader.java:1013)
at java.base/java.security.SecureClassLoader.defineClass(SecureClassLoader.java:150)
at java.base/jdk.internal.loader.BuiltinClassLoader.defineClass(BuiltinClassLoader.java:862)
at java.base/jdk.internal.loader.BuiltinClassLoader.findClassOnClassPathOrNull(BuiltinClassLoader.java:760)
at java.base/jdk.internal.loader.BuiltinClassLoader.loadClassOrNull(BuiltinClassLoader.java:681)
at java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(BuiltinClassLoader.java:639)
at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(ClassLoaders.java:188)
at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:521)
at com.tugalsan.api.thread.server.TS_ThreadFetchAll.<init>(TS_ThreadFetchAll.java:44)
at com.tugalsan.api.thread.server.TS_ThreadFetchAll.of(TS_ThreadFetchAll.java:85)
at com.tugalsan.tst.thread.Main.main(Main.java:13)
Caused by: java.lang.ClassNotFoundException: jdk.incubator.concurrent.StructuredTaskScope
at java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(BuiltinClassLoader.java:641)
at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(ClassLoaders.java:188)
at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:521)
... 12 more
I also tried adding '=' character, but no luck: java -jar target/com.tugalsan.tst.thread-1.0-SNAPSHOT-jar-with-dependencies.jar --enable-preview --add-modules=jdk.incubator.concurrent
As Joachim Sauer answered:
Everything after the -jar filename.jar will be passed as an argument.
Hence to run an app with jdk.incubator.concurrent, one should use below order:
java --enable-preview --add-modules jdk.incubator.concurrent -jar JARFILENAME.jar argument0 argument1 argument2...

Can't able to run Groovy script in Jmeter

When I execute the groovy script in JSR223 Post processor,I get the following error.The script works fine with earlier version but when upgraded to Jmeter5.4.2 it throws this error.
021-12-20 19:47:02,491 WARN o.a.j.f.Groovy: Error running groovy script
javax.script.ScriptException: javax.script.ScriptException: groovy.lang.MissingPropertyException: No such property: AESUtil for class: Script4
at org.codehaus.groovy.jsr223.GroovyScriptEngineImpl.eval(GroovyScriptEngineImpl.java:162) ~[groovy-all-2.4.16.jar:2.4.16]
at javax.script.AbstractScriptEngine.eval(Unknown Source) ~[?:1.8.0_201]
at org.apache.jmeter.functions.Groovy.execute(Groovy.java:120) [ApacheJMeter_functions.jar:5.4.2]
at org.apache.jmeter.engine.util.CompoundVariable.execute(CompoundVariable.java:138) [ApacheJMeter_core.jar:5.4.2]
at org.apache.jmeter.engine.util.CompoundVariable.execute(CompoundVariable.java:113) [ApacheJMeter_core.jar:5.4.2]
at org.apache.jmeter.testelement.property.FunctionProperty.getStringValue(FunctionProperty.java:100) [ApacheJMeter_core.jar:5.4.2]
at org.apache.jmeter.testelement.AbstractTestElement.getPropertyAsString(AbstractTestElement.java:280) [ApacheJMeter_core.jar:5.4.2]
at org.apache.jmeter.protocol.http.sampler.HTTPSamplerBase.getPath(HTTPSamplerBase.java:508) [ApacheJMeter_http.jar:5.4.2]
at org.apache.jmeter.protocol.http.sampler.HTTPSamplerBase.getUrl(HTTPSamplerBase.java:1079) [ApacheJMeter_http.jar:5.4.2]
at org.apache.jmeter.protocol.http.sampler.HTTPSamplerBase.sample(HTTPSamplerBase.java:1296) [ApacheJMeter_http.jar:5.4.2]
at org.apache.jmeter.protocol.http.sampler.HTTPSamplerBase.sample(HTTPSamplerBase.java:1285) [ApacheJMeter_http.jar:5.4.2]
at org.apache.jmeter.threads.JMeterThread.doSampling(JMeterThread.java:638) [ApacheJMeter_core.jar:5.4.2]
at org.apache.jmeter.threads.JMeterThread.executeSamplePackage(JMeterThread.java:558) [ApacheJMeter_core.jar:5.4.2]
at org.apache.jmeter.threads.JMeterThread.processSampler(JMeterThread.java:489) [ApacheJMeter_core.jar:5.4.2]
at org.apache.jmeter.threads.JMeterThread.run(JMeterThread.java:256) [ApacheJMeter_core.jar:5.4.2]
at java.lang.Thread.run(Unknown Source) [?:1.8.0_201]
Caused by: javax.script.ScriptException: groovy.lang.MissingPropertyException: No such property: AESUtil for class: Script4
at org.codehaus.groovy.jsr223.GroovyScriptEngineImpl.eval(GroovyScriptEngineImpl.java:324) ~[groovy-all-2.4.16.jar:2.4.16]
at org.codehaus.groovy.jsr223.GroovyScriptEngineImpl.eval(GroovyScriptEngineImpl.java:159) ~[groovy-all-2.4.16.jar:2.4.16]
... 15 more
Caused by: groovy.lang.MissingPropertyException: No such property: AESUtil for class: Script4
at org.codehaus.groovy.runtime.ScriptBytecodeAdapter.unwrap(ScriptBytecodeAdapter.java:53) ~[groovy-2.4.6.jar:2.4.6]
at org.codehaus.groovy.runtime.callsite.PogoGetPropertySite.getProperty(PogoGetPropertySite.java:52) ~[groovy-2.4.6.jar:2.4.6]
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callGroovyObjectGetProperty(AbstractCallSite.java:307) ~[groovy-2.4.6.jar:2.4.6]
at Script4.run(Script4.groovy:1) ~[?:?]
at org.codehaus.groovy.jsr223.GroovyScriptEngineImpl.eval(GroovyScriptEngineImpl.java:321) ~[groovy-all-2.4.16.jar:2.4.16]
at org.codehaus.groovy.jsr223.GroovyScriptEngineImpl.eval(GroovyScriptEngineImpl.java:159) ~[groovy-all-2.4.16.jar:2.4.16]
... 15 more
You "Can't able to run Groovy script in Jmeter" because you're trying to use AESUtil class (whatever it is) and the class is not known to JMeter/Groovy
In order to be able to use AESUtil class you need to put it under JMeter Classpath (copy the .jar providing the class to "lib" folder of your JMeter installation)
Also looking into dependencies for JMeter 5.4.2 it seems that JMeter uses groovy version 3.0.7 and from your log file it appears that you're having groovy-all-2.4.16.jar so I would recommend removing it from JMeter Classpath in order to avoid potential Jar Hell
More information: How to Reuse Your JMeter Code with JAR Files and Save Time

Issue with classloader

I am trying to move legacy application (ear application) from Websphere to liberty.
However on startup I am getting lot of "ClassNotFound" errors like
Caused by: java.lang.NoClassDefFoundError: com.abc.utilities.BaseServletFil
at java.lang.ClassLoader.defineClassImpl(Native Method)
at java.lang.ClassLoader.defineClassInternal(ClassLoader.java:397)
at java.lang.ClassLoader.defineClass(ClassLoader.java:358)
at com.ibm.ws.classloading.internal.AppClassLoader.definePackageAndClass(AppClassLoader.java:375)
at com.ibm.ws.classloading.internal.AppClassLoader.findClass(AppClassLoader.java:285)
at java.lang.ClassLoader.loadClassHelper(ClassLoader.java:943)
at java.lang.ClassLoader.loadClass(ClassLoader.java:888)
at com.ibm.ws.classloading.internal.AppClassLoader.findOrDelegateLoadClass(AppClassLoader.java:535)
at com.ibm.ws.classloading.internal.AppClassLoader.loadClass(AppClassLoader.java:495)
at java.lang.ClassLoader.loadClass(ClassLoader.java:871)
at com.ibm.ws.classloading.internal.UnifiedClassLoader.findClass(UnifiedClassLoader.java:127)
at
com.ibm.ws.classloading.internal.ThreadContextClassLoader.findClass(ThreadContextClassLoader.java:138)
at java.lang.ClassLoader.loadClassHelper(ClassLoader.java:943)
at java.lang.ClassLoader.loadClass(ClassLoader.java:888)
at com.ibm.ws.classloading.internal.UnifiedClassLoader.loadClass0(UnifiedClassLoader.java:113)
at com.ibm.ws.classloading.internal.UnifiedClassLoader$Delegation.loadClass(UnifiedClassLoader.java:82)
at com.ibm.ws.classloading.internal.UnifiedClassLoader.loadClass(UnifiedClassLoader.java:106)
at com.ibm.ws.classloading.internal.ThreadContextClassLoader.loadClass(ThreadContextClassLoader.java:154)
at java.lang.ClassLoader.loadClass(ClassLoader.java:871)
at com.ibm.ws.webcontainer.filter.WebAppFilterManager._loadFilter(WebAppFilterManager.java:588)
... 17 more
Caused by: java.lang.ClassNotFoundException:
com.abc.utilities.BaseServletFil
at com.ibm.ws.classloading.internal.AppClassLoader.findClassCommonLibraryClassLoaders(AppClassLoader.java:557)
at com.ibm.ws.classloading.internal.AppClassLoader.findClass(AppClassLoader.java:288)
at java.lang.ClassLoader.loadClassHelper(ClassLoader.java:943)
at java.lang.ClassLoader.loadClass(ClassLoader.java:888)
at com.ibm.ws.classloading.internal.AppClassLoader.findOrDelegateLoadClass(AppClassLoader.java:535)
at com.ibm.ws.classloading.internal.AppClassLoader.loadClass(AppClassLoader.java:495)
at java.lang.ClassLoader.loadClass(ClassLoader.java:871)
... 37 more
BaseServletFil is defined in abc.jar which is not bundled inside the ear
To resolve the error, I added following configuration to server.xml
<application id="ABC_EJBEAR" location="abcuiejb.ear" name="ABC_EJBEAR">
<classloader>
<privateLibrary>
<fileset dir="${server.config.dir}/myLibrary" includes="*.jar" scanInterval="5s" />
</privateLibrary>
</classloader>
</application>
myLibrary directory is created at wlp\usr\servers\server1\myLibrary and contains abc.jar.
Any pointers in resolving this error will be helpful. Also how to troubleshoot classloading issues (for third party jars like apache commons)

Spring Framework: Why command line argument "--argument-name=" throws Invalid argument syntax?

For Spring Boot having the intention to execute the following command:
java -jar ./target/command-01-0.0.1-SNAPSHOT.jar --user-name= (two - and = )
Throws
[main] ERROR org.springframework.boot.SpringApplication - Application run failed
java.lang.IllegalArgumentException: Invalid argument syntax: ---user-name=
at org.springframework.core.env.SimpleCommandLineArgsParser.parse(SimpleCommandLineArgsParser.java:75)
at org.springframework.core.env.SimpleCommandLinePropertySource.<init>(SimpleCommandLinePropertySource.java:90)
at org.springframework.boot.DefaultApplicationArguments$Source.<init>(DefaultApplicationArguments.java:76)
at org.springframework.boot.DefaultApplicationArguments.<init>(DefaultApplicationArguments.java:42)
at org.springframework.boot.SpringApplication.run(SpringApplication.java:307)
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1226)
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1215)
at com.manuel.jordan.Command01Application.main(Command01Application.java:21)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.base/java.lang.reflect.Method.invoke(Method.java:566)
at org.springframework.boot.loader.MainMethodRunner.run(MainMethodRunner.java:48)
at org.springframework.boot.loader.Launcher.launch(Launcher.java:87)
at org.springframework.boot.loader.Launcher.launch(Launcher.java:51)
at org.springframework.boot.loader.JarLauncher.main(JarLauncher.java:52)
But If use:
java -jar ./target/command-01-0.0.1-SNAPSHOT.jar -user-name= (one - and =)
java -jar ./target/command-01-0.0.1-SNAPSHOT.jar --user-name (two - and not = )
Pass
The app developed has internal validation if the argument --user-name use = and there is no value. It is not critical of course because:
The value would be assumed how empty and a default internal value should be assumed.
Either --user-name or -user-name= arguments can be used instead too.
Why Spring Boot has this control validation?. What is the reason about this?

Jetty Annotation Timeout Reason

I am tying to run my web application with maven jetty plugin. But after some time at startup, it gives the error:
[INFO] Web defaults = org/eclipse/jetty/webapp/webdefault.xml
[INFO] Web overrides = none
2014-08-10 17:39:45.840:INFO:oejs.Server:main: jetty-9.2.2.v20140723
2014-08-10 17:40:54.961:WARN:oejw.WebAppContext:main: Failed startup of context o.e.j.m.p.JettyWebAppContext#1e2c8{/asd,file:/C:/dev/project/hope/target/asd-1.0/,STARTING}{C:\dev\project\hope\target\asd-1.0.war}
java.lang.Exception: Timeout scanning annotations
at org.eclipse.jetty.annotations.AnnotationConfiguration.scanForAnnotations(AnnotationConfiguration.java:570)
at org.eclipse.jetty.annotations.AnnotationConfiguration.configure(AnnotationConfiguration.java:440)
at org.eclipse.jetty.webapp.WebAppContext.configure(WebAppContext.java:471)
at org.eclipse.jetty.webapp.WebAppContext.startContext(WebAppContext.java:1329)
at org.eclipse.jetty.server.handler.ContextHandler.doStart(ContextHandler.java:741)
at org.eclipse.jetty.webapp.WebAppContext.doStart(WebAppContext.java:497)
at org.eclipse.jetty.maven.plugin.JettyWebAppContext.doStart(JettyWebAppContext.java:365)
at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:68)
at org.eclipse.jetty.util.component.ContainerLifeCycle.start(ContainerLifeCycle.java:132)
at org.eclipse.jetty.util.component.ContainerLifeCycle.doStart(ContainerLifeCycle.java:114)
at org.eclipse.jetty.server.handler.AbstractHandler.doStart(AbstractHandler.java:61)
I am using spring mvc with annotations and I think there is a problem about it.
When I try to run it over eclipse jetty plugin, it starts succesfully, but with maven plugin, it gives the error.
Any ideas?
I've got the same error and to fix it, you should add to your start script (start.ini) the following:
-Dorg.eclipse.jetty.annotations.maxWait=120
120 is for two minutes of annotation scanning in case that you need a higher value, just set it to the propper one.
It is useless to scan all dependent jars, you can make the scanning pattern more restrictive to only match certain jars:
<plugin>
<groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-maven-plugin</artifactId>
<version>9.2.8.v20150217</version>
<configuration>
<webAppConfig>
<contextPath>/</contextPath>
<webInfIncludeJarPattern>.*/foo-[^/]*\.jar$|.*/classes/.*</webInfIncludeJarPattern>
</webAppConfig>
</configuration>
</plugin>
See webInfIncludeJarPattern doc for more details:
http://www.eclipse.org/jetty/documentation/9.4.x/jetty-maven-plugin.html#configuring-your-webapp
One more (in my opinion) convinient way is to set this property using a jetty.xml like so:
<?xml version="1.0"?>
<!DOCTYPE Configure PUBLIC "-//Jetty//Configure//EN" "http://www.eclipse.org/jetty/configure.dtd">
<Configure>
<Call name="setProperty" class="java.lang.System">
<Arg>org.eclipse.jetty.annotations.maxWait</Arg>
<Arg>120</Arg>
</Call>
</Configure>
This way you can omit the commandline args
The most simple way is adding the system property in pom.xml
https://www.eclipse.org/jetty/documentation/9.4.x/jetty-maven-plugin.html#setting-system-properties
This message means scanning annotation took time more than its being configured thus timeout so this can be fixed either by increasing the timeout period (Dorg.eclipse.jetty.annotations.maxWait=120) or by deleting the tmp / webapp-tmp from target which reduces its scan time.
The property (-Dorg.eclipse.jetty.annotations.maxWait=120) can be added to start.ini so it works for all the webapps in your app base.

Resources