Today I had the idea to build a very simple web application, which would be powered by a REST backend. Since I wanted a very lightweight server I started looking at Jetty. And since I wanted to try another JAX-RS implementation than Jersey I looked at RestEasy. I thought those 2 would be easy to implement. I was wrong...
I imported the basic Jetty server and servlet dependencies since I thought that were the only server requirements for a basic (REST only) Jetty server (I alto tried to use the webapp dependency; this gave the same errors).
<dependency>
<groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-server</artifactId>
<version>9.0.0.RC0</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-servlet</artifactId>
<version>9.0.0.RC0</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-servlets</artifactId>
<version>9.0.0.RC0</version>
<scope>compile</scope>
</dependency>
Then I imported the basic RestEasy dependencies.
<dependency>
<groupId>org.jboss.resteasy</groupId>
<artifactId>resteasy-jaxrs</artifactId>
<version>3.0.1.Final</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>org.jboss.resteasy</groupId>
<artifactId>resteasy-jaxb-provider</artifactId>
<version>3.0.1.Final</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>org.jboss.resteasy</groupId>
<artifactId>async-http-servlet-3.0</artifactId>
<version>3.0.1.Final</version>
<scope>compile</scope>
</dependency>
Main method:
public class ExampleActivator {
public static void main(String args[]) throws Exception {
Server server = new Server(8080);
ServletContextHandler context = new ServletContextHandler(ServletContextHandler.NO_SESSIONS);
context.setContextPath("/");
ServletHolder h = new ServletHolder(new HttpServlet30Dispatcher());
h.setInitParameter("javax.ws.rs.Application", "packages.ExampleResources");
context.addServlet(h, "/*");
server.setHandler(context);
server.start();
server.join();
}
}
ExampleResources:
public class ExampleResources extends Application {
private static final ImmutableSet services = ImmutableSet.of(
ExampleResourceImpl.class
);
#Override
public Set<Class<?>> getClasses() {
return services;
}
}
ExampleResourceImpl:
#Path("activities")
public class ExampleResourceImpl {
#GET
#Produces(MediaType.TEXT_PLAIN)
public String getAll() {
return "Hello World";
}
}
When I go to the webapge I get the following trace:
250 [main] INFO org.eclipse.jetty.server.Server - jetty-9.0.0.RC0
911 [main] INFO org.jboss.resteasy.spi.ResteasyDeployment - Deploying javax.ws.rs.core.Application: class packages.ExampleResources
939 [main] INFO org.jboss.resteasy.spi.ResteasyDeployment - Adding class resource packages.ExampleResourceImpl from Application class packages.ExampleResources
1005 [main] INFO org.eclipse.jetty.server.handler.ContextHandler - started o.e.j.s.ServletContextHandler#702ab48{/,null,AVAILABLE}
1037 [main] INFO org.eclipse.jetty.server.ServerConnector - Started ServerConnector#465ed596{HTTP/1.1}{0.0.0.0:8080}
6315 [qtp84346444-13] WARN org.eclipse.jetty.servlet.ServletHandler - Error for /activities
java.lang.NoSuchMethodError: org.jboss.resteasy.specimpl.BuiltResponse.getHeaders()Ljavax/ws/rs/core/MultivaluedMap;
at org.jboss.resteasy.core.ServerResponseWriter.setDefaultContentType(ServerResponseWriter.java:195)
at org.jboss.resteasy.core.ServerResponseWriter.writeNomapResponse(ServerResponseWriter.java:46)
at org.jboss.resteasy.core.SynchronousDispatcher.writeResponse(SynchronousDispatcher.java:411)
at org.jboss.resteasy.core.SynchronousDispatcher.invoke(SynchronousDispatcher.java:376)
at org.jboss.resteasy.core.SynchronousDispatcher.invoke(SynchronousDispatcher.java:179)
at org.jboss.resteasy.plugins.server.servlet.ServletContainerDispatcher.service(ServletContainerDispatcher.java:220)
at org.jboss.resteasy.plugins.server.servlet.HttpServletDispatcher.service(HttpServletDispatcher.java:56)
at org.jboss.resteasy.plugins.server.servlet.HttpServletDispatcher.service(HttpServletDispatcher.java:51)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:848)
at org.eclipse.jetty.servlet.ServletHolder.handle(ServletHolder.java:671)
at org.eclipse.jetty.servlet.ServletHandler.doHandle(ServletHandler.java:448)
at org.eclipse.jetty.server.handler.ContextHandler.doHandle(ContextHandler.java:1070)
at org.eclipse.jetty.servlet.ServletHandler.doScope(ServletHandler.java:375)
at org.eclipse.jetty.server.handler.ContextHandler.doScope(ContextHandler.java:1004)
at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:136)
at org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:97)
at org.eclipse.jetty.server.Server.handle(Server.java:449)
at org.eclipse.jetty.server.HttpChannel.run(HttpChannel.java:246)
at org.eclipse.jetty.server.HttpConnection.onFillable(HttpConnection.java:265)
at org.eclipse.jetty.io.AbstractConnection$ReadCallback.run(AbstractConnection.java:240)
at org.eclipse.jetty.util.thread.QueuedThreadPool.runJob(QueuedThreadPool.java:589)
at org.eclipse.jetty.util.thread.QueuedThreadPool$3.run(QueuedThreadPool.java:520)
at java.lang.Thread.run(Thread.java:722)
Normally this would mean that I forgot a dependency, however I really have no clue what's going on.
I just stumbled upon the same issue. The solution was to add the jaxrs-api explicitly as the first dependency in the list of dependencies.
<dependencies>
<!-- jaxrs-api is the very first dependency -->
<dependency>
<groupId>org.jboss.resteasy</groupId>
<artifactId>jaxrs-api</artifactId>
<version>3.0.4.Final</version>
</dependency>
<!-- here come the other depdendencies -->
</dependencies>
Jackson uses the jsr311-api that provides the same Response class that is used by the BuiltResponse class. Unfortunately, this Response does not contain the getHeaders() method. So even though the dependency is resolved, it is using a wrong class. If somehow the Jackson dependency gets before the Resteasy one, then the exception above will be raised.
I had the very same problem. First of all it was working using JAX-RS 2 and then it was migrated to JAX-RS 3, so I thought it had something to do with that. After failing in trying to get JBoss use JAX-RS 3 from app via Maven and jboss-deployment-structure.xml, I tried upgrading JBoss modules, which can be done using the following procedure:
3.1. Upgrading Resteasy Within JBoss AS 7
Resteasy is bundled with JBoss AS 7. You will likely have the need to upgrade Resteasy in AS7.
The Resteasy distribution comes with a zip file called resteasy-jboss-modules-3.0.1.Final.zip.
Unzip this file while with the modules/ directory of the JBoss AS7 distribution. This will overwrite
some of the existing files there.
Source: http://docs.jboss.org/resteasy/docs/3.0.1.Final/userguide/pdf/resteasy-reference-guide-en-US.pdf
Hope it helps!
Had the very same problem when trying to deploy a jax-rs (with resteasy) to glassfish 3.1.2.2. Tried to resolve what caused the inconsistency, took for hours and couldn't find it in the end - glassfish behavior became more and more strange.
My recommendation for everyone trying to run resteasy on gf: stop it and use jersey.
I ran into this issue as well and it took me forever to figure out how to resolve it. Kevin Day was right. The issue was that one of the dependencies in my POM indirectly pulled in Jackson and that dependency was placed in the POM file before the jaxrs dependency. A fix was to simply move the jaxrs dependency to the top of the POM file so it gets picked up before Jackson.
Related
i'm trying to generate class stubs for a wsdl with Intellij-Idea 2017.2.5 (Webservices -> Generate code from wsdl...) using JDK-9
I'm getting this exception and i wonder how to tell intellij to pass "--add-modules java.activation" to complete the operation.
(i guess i should run wsimport from the command line...)
Exception in thread "main" java.lang.NoClassDefFoundError: javax/activation/DataSource
at com.sun.xml.bind.v2.model.impl.RuntimeBuiltinLeafInfoImpl.<clinit>(RuntimeBuiltinLeafInfoImpl.java:461)
at com.sun.xml.bind.v2.model.impl.RuntimeTypeInfoSetImpl.<init>(RuntimeTypeInfoSetImpl.java:65)
at com.sun.xml.bind.v2.model.impl.RuntimeModelBuilder.createTypeInfoSet(RuntimeModelBuilder.java:133)
at com.sun.xml.bind.v2.model.impl.RuntimeModelBuilder.createTypeInfoSet(RuntimeModelBuilder.java:85)
at com.sun.xml.bind.v2.model.impl.ModelBuilder.<init>(ModelBuilder.java:156)
at com.sun.xml.bind.v2.model.impl.RuntimeModelBuilder.<init>(RuntimeModelBuilder.java:93)
at com.sun.xml.bind.v2.runtime.JAXBContextImpl.getTypeInfoSet(JAXBContextImpl.java:455)
at com.sun.xml.bind.v2.runtime.JAXBContextImpl.<init>(JAXBContextImpl.java:303)
at com.sun.xml.bind.v2.runtime.JAXBContextImpl.<init>(JAXBContextImpl.java:142)
at com.sun.xml.bind.v2.runtime.JAXBContextImpl$JAXBContextBuilder.build(JAXBContextImpl.java:1174)
at com.sun.tools.xjc.reader.xmlschema.bindinfo.BindInfo.getJAXBContext(BindInfo.java:335)
at com.sun.tools.xjc.reader.internalizer.SCDBasedBindingSet.apply(SCDBasedBindingSet.java:235)
at com.sun.tools.xjc.ModelLoader.createXSOM(ModelLoader.java:541)
at com.sun.tools.xjc.api.impl.s2j.SchemaCompilerImpl.bind(SchemaCompilerImpl.java:269)
at com.sun.tools.xjc.api.impl.s2j.SchemaCompilerImpl.bind(SchemaCompilerImpl.java:95)
at com.sun.tools.ws.processor.modeler.wsdl.JAXBModelBuilder.bind(JAXBModelBuilder.java:142)
at com.sun.tools.ws.processor.modeler.wsdl.WSDLModeler.buildJAXBModel(WSDLModeler.java:2244)
at com.sun.tools.ws.processor.modeler.wsdl.WSDLModeler.internalBuildModel(WSDLModeler.java:191)
at com.sun.tools.ws.processor.modeler.wsdl.WSDLModeler.buildModel(WSDLModeler.java:137)
at com.sun.tools.ws.wscompile.WsimportTool.buildWsdlModel(WsimportTool.java:391)
at com.sun.tools.ws.wscompile.WsimportTool.run(WsimportTool.java:204)
at com.sun.tools.ws.wscompile.WsimportTool.run(WsimportTool.java:179)
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:564)
at com.sun.tools.ws.Invoker.invoke(Invoker.java:135)
at com.sun.tools.ws.WsImport.main(WsImport.java:57)
Caused by: java.lang.ClassNotFoundException: javax.activation.DataSource
at java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(BuiltinClassLoader.java:582)
at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(ClassLoaders.java:185)
at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:496)
... 28 more
Based on your error message, you need to add the following dependency in your pom.xml
<dependency>
<groupId>javax.activation</groupId>
<artifactId>activation</artifactId>
<version>1.1.1</version>
</dependency>
From SDK 9, for JAXB to work for web services you need to also have the following dependencies if you do not already have them as they are not part of the SDK.
<dependency>
<groupId>javax.xml.bind</groupId>
<artifactId>jaxb-api</artifactId>
<version>2.3.0</version>
</dependency>
<dependency>
<groupId>com.sun.xml.bind</groupId>
<artifactId>jaxb-core</artifactId>
<version>2.3.0</version>
</dependency>
<dependency>
<groupId>com.sun.xml.bind</groupId>
<artifactId>jaxb-impl</artifactId>
<version>2.3.0</version>
</dependency>
I guess it can be useful. I have these additional packages in my soap project when switch from Java 8 to 10. Gradle:
compile "javax.xml.bind:jaxb-api:2.3.0"
compile "javax.activation:activation:1.1"
compile "com.sun.xml.bind:jaxb-impl:2.3.0"
compile "com.sun.xml.bind:jaxb-core:2.3.0"
compile "com.sun.xml.ws:rt:2.3.0"
compile "com.sun.xml.ws:jaxws-rt:2.3.0"
Just for other people with the same exception coming here:
This problem can also occur if you use a web server such as tomcat and if you need the activation jar to be present there as well. One possible solution is to put it in the lib folder of tomcat (or to use the common.loader functionality).
I had the same problem. After changing the project jdk, it works for me.
Change project jdk to 8.
I'm trying to add a Neo4j connection to my spring boot web application. I'm using this example at a template, but can't seem to get things working.
I keep getting a runtime error about not being able to create a SessionFactory: "Failed to instantiate [org.neo4j.ogm.session.SessionFactory]: Factory method 'sessionFactory' threw exception; nested exception is java.lang.NullPointerException"
I'm using spring boot version 1.5.1.RELEASE and here's the dependencies from my pom.xml file:
<dependencyManagement>
<dependencies>
<dependency>
<!-- Import dependency management from Spring Boot -->
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-dependencies</artifactId>
<version>1.5.1.RELEASE</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>
<dependencies>
<!-- For REST HTTP service and injection interfaces-->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-devtools</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-thymeleaf</artifactId>
</dependency>
<!-- For websocket service support -->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-websocket</artifactId>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-messaging</artifactId>
</dependency>
<!-- For security features (user authentication, SSL) -->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-security</artifactId>
</dependency>
<!-- For Neo4j integration -->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-neo4j</artifactId>
</dependency>
</dependencies>
Here's my Spring Application Class:
#SpringBootApplication
#EnableTransactionManagement
#EnableNeo4jRepositories(basePackages="mycompany.ocelot.entities")
public class ServiceApp {
public static void main(String[] args) {
SpringApplication.run(ServiceApp.class, args);
}
}
Here's my entity class:
package mycompany.ocelot.entities;
import java.util.HashSet;
import java.util.Set;
import org.neo4j.ogm.annotation.GraphId;
import org.neo4j.ogm.annotation.NodeEntity;
import org.neo4j.ogm.annotation.Relationship;
#NodeEntity
public class User {
#GraphId private Long id;
private String username;
#SuppressWarnings("unused")
private User(){
// required by Neo4j
}
public User(String username){
this.username = username;
}
// getters & setters
public Long getId() {
return id;
}
public String getUsername() {
return username;
}
public void setUsername(String username) {
this.username = username;
}
public String toString(){
return username;
}
}
Here's my UserRepository class:
package mycompany.ocelot.entities;
import java.util.List;
import org.springframework.data.neo4j.repository.GraphRepository;
import org.springframework.data.repository.CrudRepository;
public interface UserRepository extends GraphRepository<User> {
User findByUsername(String username);
}
Here's the runtime error:
2017-02-23 19:55:04.928 WARN 4387 --- [ main] ationConfigEmbeddedWebApplicationContext : Exception encountered during context initialization - cancelling refresh attempt: org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'neo4jAuthenticationProvider': Unsatisfied dependency expressed through field 'user_repository'; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'userRepository': Unsatisfied dependency expressed through method 'setSession' parameter 0; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.springframework.data.neo4j.transaction.SharedSessionCreator#0': Cannot resolve reference to bean 'sessionFactory' while setting constructor argument; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sessionFactory' defined in class path resource [org/springframework/boot/autoconfigure/data/neo4j/Neo4jDataAutoConfiguration.class]: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.neo4j.ogm.session.SessionFactory]: Factory method 'sessionFactory' threw exception; nested exception is java.lang.NullPointerException
2017-02-23 19:55:04.932 WARN 4387 --- [ main] o.s.boot.SpringApplication : Error handling failed (Error creating bean with name 'delegatingApplicationListener' defined in class path resource [org/springframework/security/config/annotation/web/configuration/WebSecurityConfiguration.class]: Initialization of bean failed; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.springframework.transaction.annotation.ProxyTransactionManagementConfiguration': Initialization of bean failed; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No bean named 'org.springframework.context.annotation.ConfigurationClassPostProcessor.importRegistry' available)
I tried adding a Neo4j configuration class, but I just get a similar error.
package mycompany.ocelot.entities;
import org.neo4j.ogm.session.SessionFactory;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.data.neo4j.repository.config.EnableNeo4jRepositories;
import org.springframework.data.neo4j.transaction.Neo4jTransactionManager;
import org.springframework.transaction.annotation.EnableTransactionManagement;
#Configuration
#EnableNeo4jRepositories(basePackages = "mycompany.ocelot.entities")
#EnableTransactionManagement
public class Neo4jConfiguration {
#Bean
public Neo4jTransactionManager transactionManager() {
return new Neo4jTransactionManager(sessionFactory());
}
#Bean
public SessionFactory sessionFactory() {
// with domain entity base package(s)
return new SessionFactory("mycompany.ocelot.entities");
}
}
Update 1:
In trying to debug this, I tried removing things to determine when the problem starts happening. And I discovered that just including the dependency to the pom file causes the same exception. So I'm guessing there's some conflict between the spring modules I'm including.
Update 2:
I removed a dependency to another internal java project (which I didn't include in the pom file posted above) and that removed the runtime error. I did have to comment out quite a bit of code in this project as a result. So, the problem isn't between the spring modules, but somewhere between our code and spring-data-neo4j. Does anyone have any pointers on how to track down these kind of errors? The logging and stack trace don't seem much help as they don't reference our code. My knowledge spring's IoC (which I think is where the problem is) isn't that deep so any pointers on where to start would be helpful.
I ran the application from https://spring.io/guides/gs/accessing-data-neo4j without any issue with using the HTTP driver. I then added your other dependencies and had no issue either.
Try using upgrading to Boot 1.5.2 and do the following:
Remove the annotations: #EnableTransactionManagement and #EnableNeo4jRepositories(basePackages="mycompany.ocelot.entities"). These should already be configured by Spring Boot.
Add #EntityScan("<package containing your model code>") below #SpringBootApplication
Delete Neo4jConfiguration.
Make sure your configuration has the right username and password for your Neo4j database.
I faced a similar issue when I upgraded my application to Spring Boot version 1.5.2 - several null pointers at various places during Neo4j auto-configuration.
The issue to me was, that with the release of SDN 4.2 (which is referenced by the new Spring Boot version), the Neo4j's embedded driver does no longer include the neo4j kernel (see here). After I added the following two dependencies my application was up and running again.
<dependency>
<groupId>org.neo4j</groupId>
<artifactId>neo4j-ogm-embedded-driver</artifactId>
<version>2.1.1</version>
</dependency>
<dependency>
<groupId>org.neo4j</groupId>
<artifactId>neo4j</artifactId>
<version>3.1.1</version>
</dependency>
Maybe this can solve your problem as well.
I've just seen the same error in code I'm writing this morning: SessionFactory: "Failed to instantiate [org.neo4j.ogm.session.SessionFactory]: Factory method 'sessionFactory' threw exception; nested exception is java.lang.NullPointerException"
The problem occurred reliably and repeatable each time I started the application (which is a Spring Boot application implementing CommandLineRunner and connection to a Neo4j graph database).
I removed .java files one at a time (as D Perkins suggested in 'Update 2' above) until I tracked it down to a very simple piece of code, effectively:
package com.xxx.xxxx;
import java.nio.file.Path;
import lombok.Data;
#Data
public class MyClass {
private Path file;
private String content;
}
I've managed to avoid the problem by changing that class to use java.io.File rather than java.nio.file.Path. i.e. private File file;
Things I tried which didn't work included:
Replacing #Data with #Getter and #Setter.
Removing Lombok from the file and using source generation to create the getters and setters.
Removing the only code which called new MyClass().
I am using Lombok elsewhere in the project without issues. The project is a Spring Boot project.
I hope this information will prove useful.
While executing a Gate embedded app containing annie coreference pr I got the following error.
Gate lib was loaded using maven dependancy.
Exception in thread "main" java.lang.NoClassDefFoundError: junit/framework/Assert
at gate.creole.coref.PronominalCoref.init(PronominalCoref.java:110)
at gate.creole.coref.Coreferencer.init(Coreferencer.java:74)
at gate.Factory.createResource(Factory.java:432)
at gate.Factory.createResource(Factory.java:139)
at gate.Factory.createResource(Factory.java:121)
at com.sigmacr.OBIEPipelineBuilder.createPipeline(OBIEPipelineBuilder.java:150)
Issue solved. The junit dependency was scoped "test". While the GATE embedded coref PR used it in runtime.
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.11</version>
<scope>test-->should be runtime </scope>
</dependency>
I'm trying to build a WS with CXF. I'm following this article http://www.ibm.com/developerworks/library/ws-pojo-springcxf/
But I have 2 questions:
1) Which maven2 artifacts are necessary to build a WS with CXF and Spring?
2) I'm getting this error: FileNotFound: META-INF/cxf/cxf.xml. I don't know where this file is.
Thanks in advance
You need to make sure you have proper cxf dependencies declared.
<dependency>
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-rt-frontend-jaxws</artifactId>
<version>2.2.5</version>
</dependency>
<dependency>
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-rt-transports-http</artifactId>
<version>2.2.5</version>
</dependency>
The META-INF/cxf/cxf.xml is in cxf-rt-core-2.2.5.jar which is one of the transitive dependencies.
META-INF/cxf/cxf.xml is in cxf-2.3.0.jar
You will need these jars to run cxf webservices
commons-codec-1.3.jar
commons-collections-3.2.1.jar
commons-lang-2.4.jar
commons-logging-1.1.1.jar
commons-pool-1.5.2.jar
cxf-2.3.0.jar
cxf-manifest.jar
geronimo-activation_1.1_spec-1.0.2.jar
geronimo-annotation_1.0_spec-1.1.1.jar
geronimo-javamail_1.4_spec-1.6.jar
geronimo-jaxws_2.1_spec-1.0.jar
geronimo-stax-api_1.0_spec-1.0.1.jar
geronimo-ws-metadata_2.0_spec-1.1.2.jar
jaxb-api-2.2.1.jar
jaxb-impl-2.2.1.1.jar
jaxb-xjc-2.2.1.1.jar
jstl.jar
log4j-1.2.15.jar
spring-aop-3.0.4.RELEASE.jar
spring-asm-3.0.4.RELEASE.jar
spring-beans-3.0.4.RELEASE.jar
spring-context-3.0.4.RELEASE.jar
spring-core-3.0.4.RELEASE.jar
spring-expression-3.0.4.RELEASE.jar
spring-jms-3.0.4.RELEASE.jar
spring-tx-3.0.4.RELEASE.jar
spring-web-3.0.4.RELEASE.jar
standard.jar
wsdl4j-1.6.2.jar
wss4j-1.5.9.jar
xalan-2.7.1.jar
xml-resolver-1.2.jar
xmlbeans-2.4.0.jar
XmlSchema-1.4.7.jar
xmlsec-1.4.3.jar
I developed a webservice and deployed it to websphere 7.0 and developed a dynamic dispatch client using JAX-WS APIs which also runs on same application server.
I get error at the following line:
Dispatch<SOAPMessage> dispatch = service.createDispatch(portName, SOAPMessage.class, Service.Mode.MESSAGE);
Error:
Caused by: java.lang.NoSuchMethodError: com/sun/istack/logging/Logger.getLogger(Ljava/lang/Class;)Lcom/sun/istack/logging/Logger;
at com.sun.xml.ws.api.config.management.policy.ManagementAssertion.<clinit>(ManagementAssertion.java:87)
at java.lang.J9VMInternals.initializeImpl(Native Method)
at java.lang.J9VMInternals.initialize(J9VMInternals.java:200)
at java.lang.J9VMInternals.initialize(J9VMInternals.java:167)
at com.sun.xml.ws.server.MonitorBase.createManagedObjectManager(MonitorBase.java:177)
at com.sun.xml.ws.client.Stub.<init>(Stub.java:196)
at com.sun.xml.ws.client.Stub.<init>(Stub.java:174)
at com.sun.xml.ws.client.dispatch.DispatchImpl.<init>(DispatchImpl.java:129)
at com.sun.xml.ws.client.dispatch.SOAPMessageDispatch.<init>(SOAPMessageDispatch.java:77)
at com.sun.xml.ws.api.pipe.Stubs.createSAAJDispatch(Stubs.java:143)
at com.sun.xml.ws.api.pipe.Stubs.createDispatch(Stubs.java:264)
at com.sun.xml.ws.client.WSServiceDelegate.createDispatch(WSServiceDelegate.java:390)
at com.sun.xml.ws.client.WSServiceDelegate.createDispatch(WSServiceDelegate.java:401)
at com.sun.xml.ws.client.WSServiceDelegate.createDispatch(WSServiceDelegate.java:383)
at javax.xml.ws.Service.createDispatch(Service.java:336)
I included the following dependency.
<dependency>
<groupId>javax.xml.ws</groupId>
<artifactId>jaxws-api</artifactId>
<version>2.1</version>
</dependency>
I also tried adding policy dependency (versions - 2.2 and 2.2.1)
<dependency>
<groupId>com.sun.xml.ws</groupId>
<artifactId>policy</artifactId>
<version>2.2.1</version>
</dependency>
Any ideas on what more dependencies I need to add?
The jaxb-impl jar (2.2) contains the same logging classes as the istack-commons-runtime jar.
Add the following exclusions in order to correct the version mismatch:
<dependency>
<groupId>com.sun.xml.ws</groupId>
<artifactId>jaxws-rt</artifactId>
<version>2.2</version>
<exclusions>
<exclusion>
<artifactId>istack-commons-runtime</artifactId>
<groupId>com.sun.istack</groupId>
</exclusion>
</exclusions>
</dependency>
I believe that JAX-WS 2.1 is already built into Java 6, so you shouldn't need to bundle it with your application (assuming you're using Java 6, that is). If you try, you're likely to get classloading errors like this one.
Try removing all of the jax-ws JARs from the app, including jaxws-api.
The problem is the fact that there are likely multiple occurrences of this class - Logger (com.sun.istack.logging.Logger) in the class path.
When the code is compiled it had access to this Logger class which is different from what is found by the run time.
Two possibilities:
There in only one copy of Logger in run time and it does not match what was used during compilation.
There are multiple copies of this Logger and the class loader finds the incorrect copy first hence reports this error.
Check the JARs that contains this file.
It is typically found in jaxb-osgi.jar.
HTH
Manglu
I had the same issue and the problem was related with jaxb version compatibility. Apache Camel camel-core dependency was importing jaxb-core and jaxb-impl. Removing them from the dependency from jaxws-rt solved the problem.
<dependency>
<groupId>org.apache.camel</groupId>
<artifactId>camel-core</artifactId>
<version>${org.apache.camel.version}</version>
<exclusions>
<exclusion>
<groupId>com.sun.xml.bind</groupId>
<artifactId>jaxb-core</artifactId>
</exclusion>
<exclusion>
<groupId>com.sun.xml.bind</groupId>
<artifactId>jaxb-impl</artifactId>
</exclusion>
</exclusions>
</dependency>