java.lang.NullPointerException at com.sun.faces.context.flash.ELFlash.getFlash - java

I had created a simple JSF2.0 app and it runs fine in my computer, but when I try to run it in Heroku, I get this error:
HTTP ERROR 500
Problem accessing /login.xhtml. Reason:
Server Error
Caused by:
java.lang.NullPointerException
at com.sun.faces.context.flash.ELFlash.getFlash(ELFlash.java:93)
at com.sun.faces.context.flash.ELFlash.getELFlash(ELFlash.java:124)
at com.sun.faces.context.flash.ELFlash.doPostPhaseActions(ELFlash.java:722)
at com.sun.faces.lifecycle.Phase.handleAfterPhase(Phase.java:175)
at com.sun.faces.lifecycle.Phase.doPhase(Phase.java:108)
at com.sun.faces.lifecycle.LifecycleImpl.render(LifecycleImpl.java:139)
at javax.faces.webapp.FacesServlet.service(FacesServlet.java:311)
at org.eclipse.jetty.servlet.ServletHolder.handle(ServletHolder.java:547)
at org.eclipse.jetty.servlet.ServletHandler.doHandle(ServletHandler.java:481)
at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:119)
at org.eclipse.jetty.security.SecurityHandler.handle(SecurityHandler.java:520)
at org.eclipse.jetty.server.session.SessionHandler.doHandle(SessionHandler.java:227)
at org.eclipse.jetty.server.handler.ContextHandler.doHandle(ContextHandler.java:940)
at org.eclipse.jetty.servlet.ServletHandler.doScope(ServletHandler.java:409)
at org.eclipse.jetty.server.session.SessionHandler.doScope(SessionHandler.java:186)
at org.eclipse.jetty.server.handler.ContextHandler.doScope(ContextHandler.java:874)
at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:117)
at org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:110)
at org.eclipse.jetty.server.Server.handle(Server.java:349)
at org.eclipse.jetty.server.HttpConnection.handleRequest(HttpConnection.java:441)
at org.eclipse.jetty.server.HttpConnection$RequestHandler.headerComplete(HttpConnection.java:904)
at org.eclipse.jetty.http.HttpParser.parseNext(HttpParser.java:565)
at org.eclipse.jetty.http.HttpParser.parseAvailable(HttpParser.java:217)
at org.eclipse.jetty.server.AsyncHttpConnection.handle(AsyncHttpConnection.java:46)
at org.eclipse.jetty.io.nio.SelectChannelEndPoint.handle(SelectChannelEndPoint.java:545)
at org.eclipse.jetty.io.nio.SelectChannelEndPoint$1.run(SelectChannelEndPoint.java:43)
at org.eclipse.jetty.util.thread.QueuedThreadPool.runJob(QueuedThreadPool.java:598)
at org.eclipse.jetty.util.thread.QueuedThreadPool$3.run(QueuedThreadPool.java:533)
at java.lang.Thread.run(Thread.java:636)
So, any solution to this problem?
Thanks in advance.

java.lang.NullPointerException
at com.sun.faces.context.flash.ELFlash.getFlash(ELFlash.java:93)
at com.sun.faces.context.flash.ELFlash.getELFlash(ELFlash.java:124)
I don't recognize the ELFlash#getELFlash() method as part of recent Mojarra implementations. Perhaps you're using a very early 2.0.0 implementation which has a bug related to this. Upgrading to the latest should fix this problem.
but the problem with annotations persists in Heroku
javax.el.PropertyNotFoundException: /login.xhtml #15,55 value="#{user.name}": Target Unreachable, identifier 'user' resolved to null
at com.sun.faces.facelets.el.TagValueExpression.getType(TagValueExpression.java:100‌​)
at com.sun.faces.renderkit.html_basic.HtmlBasicInputRenderer.getConvertedValue(Html‌​BasicInputRenderer.java:95)
JSF2 annotations will fail if your faces-config.xml is not properly declared conform JSF2 specification. Make sure that the <faces-config> root declaration look like this:
<faces-config
xmlns="http://java.sun.com/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-facesconfig_2_0.xsd"
version="2.0">
<!-- config here -->
</faces-config>

Related

Weblogic server guava NoSuchMethodError

I'm trying to deploy a web project with a war file on the weblogic server. But I'm getting an error like above,
java.lang.NoSuchMethodError: com.google.common.util.concurrent.MoreExecutors.directExecutor()Ljava/util/concurrent/Executor;
at com.google.common.eventbus.EventBus.<init>(EventBus.java:138)
I tried lastest and oldest versions of guava. In the oldest versions I got eventbus error (no defined this method in the old versions). In the newest versions I got the same error again.
How can I solve this problem?
EDIT: It runs clearly in my editor (IntelliJ), when I try to run it on a weblogic server I get this error in deployment.
UPDATE:
I just added a weblogic.xml file like above in my WEB-INF path. No need any other configurasyon. The problem resolved for me thanks to #luc14n0
<?xml version="1.0" encoding="UTF-8"?>
<weblogic-web-app xmlns="http://xmlns.oracle.com/weblogic/weblogic-web-app"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://xmlns.oracle.com/weblogic/weblogic-web-app http://xmlns.oracle.com/weblogic/weblogic-web-app/1.0/weblogic-web-app.xsd">
<container-descriptor>
<prefer-web-inf-classes>true</prefer-web-inf-classes>
</container-descriptor>
</weblogic-web-app>
Weblogic 12c (12.1.3) ships with its own Guava dependency at Oracle/Middleware/Oracle_Home/wlserver/modules/com.google.common_1.2.0.0_11-0-2.jar
By telling WebLogic you prefer to use your own version, you avoid the conflict where it loads the wrong library.
In case of an EAR, add the following to application.xml:
<prefer-application-packages>
<package-name>com.google.common.*</package-name>
</prefer-application-packages>
In case of a WAR, add the following to weblogic.xml:
<container-descriptor>
<prefer-web-inf-classes>true</prefer-web-inf-classes>
</container-descriptor>

java.lang.NoSuchMethodError during Elastic search start

I am getting the following error while deploying in my EAR. The exception is coming during Elastic search connection. In my EAR I have using guava version 18. Which is the recommended version for ES 2.0+ ( I am using ES 2.3.3)
weblogic.application.ModuleException: java.lang.NoSuchMethodError: com.google.common.util.concurrent.MoreExecutors.directExecutor()Ljava/util/concurrent/Executor;
at weblogic.application.internal.ExtensibleModuleWrapper.start(ExtensibleModuleWrapper.java:140)
at weblogic.application.internal.flow.ModuleListenerInvoker.start(ModuleListenerInvoker.java:124)
at weblogic.application.internal.flow.ModuleStateDriver$3.next(ModuleStateDriver.java:216)
.....
Caused By: java.lang.NoSuchMethodError: com.google.common.util.concurrent.MoreExecutors.directExecutor()Ljava/util/concurrent/Executor;
at org.elasticsearch.threadpool.ThreadPool.<clinit>(ThreadPool.java:190)
at org.elasticsearch.client.transport.TransportClient$Builder.build(TransportClient.java:131)
at com.ventyx.servicesuite.dispatcher.ESClientMgr.connect(ESClientMgr.java:80)
....
In most of the search its mentioned that its because guava jars conflict.
java.lang.NoSuchMethodError: com.google.common.util.concurrent.MoreExecutors.sameThreadExecutor
So I have added -verbose:class as Java option while running my weblogic to see if old version of guava is loaded
But to my surprise it did not find any guava jar getting loaded. But I suspect that weblogic.server.merged.jar is have google libraries prepackaged in it.
So my question is
Is there any way we could tell the container to use the jar files from the application rather than weblogic's ?
I could resolve this problem by adding a weblogic-application.xml with prefer-application-packages to my EAR.
<?xml version="1.0" encoding="UTF-8"?>
<weblogic-application xmlns="http://xmlns.oracle.com/weblogic/weblogic-application"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:wls="http://xmlns.oracle.com/weblogic/weblogic-application"
xsi:schemaLocation="http://xmlns.oracle.com/weblogic/weblogic-application http://xmlns.oracle.com/weblogic/weblogic-application/1.0/weblogic-application.xsd">
<prefer-application-packages>
<package-name>com.google.common.*</package-name>
</prefer-application-packages>
</weblogic-application>

Weblogic 12c JPA 2.1 spring boot

I want to deploy a spring boot application to weblogic 12c (12.1.2).
The application using latest spring boot libraries. I try to using prefer-web-inf-classes but I run out of luck.
If I try to using prefer-webinf-classes I got (my application is using validation api 1.1.0.Final):
weblogic.application.ModuleException: java.lang.NoSuchMethodError: javax.validation.spi.ConfigurationState.getParameterNameProvider()Ljavax/validation/ParameterNameProvider;
at weblogic.application.internal.ExtensibleModuleWrapper.start(ExtensibleModuleWrapper.java:140)
at weblogic.application.internal.flow.ModuleListenerInvoker.start(ModuleListenerInvoker.java:124)
at weblogic.application.internal.flow.ModuleStateDriver$3.next(ModuleStateDriver.java:216)
at weblogic.application.internal.flow.ModuleStateDriver$3.next(ModuleStateDriver.java:211)
at weblogic.application.utils.StateMachineDriver.nextState(StateMachineDriver.java:42)
Truncated. see log file for complete stacktrace
Caused By: java.lang.NoSuchMethodError: javax.validation.spi.ConfigurationState.getParameterNameProvider()Ljavax/validation/ParameterNameProvider;
at org.hibernate.validator.internal.engine.ValidatorFactoryImpl.<init>(ValidatorFactoryImpl.java:142)
at org.hibernate.validator.HibernateValidator.buildValidatorFactory(HibernateValidator.java:35)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
Truncated. see log file for complete stacktrace
If I try to using this configuration in web.xml:
<wls:prefer-application-packages>
<wls:package-name>antlr.*</wls:package-name>
<wls:package-name>org.apache.commons.*</wls:package-name>
<wls:package-name>org.apache.xmlbeans.*</wls:package-name>
<wls:package-name>org.springframework.*</wls:package-name>
<wls:package-name>org.hibernate.*</wls:package-name>
<wls:package-name>org.hibernate.validator.*</wls:package-name>
<wls:package-name>javax.validation.*</wls:package-name>
<wls:package-name>javax.persistence.*</wls:package-name>
<wls:package-name>javax.validation.spi.*</wls:package-name>
<wls:package-name>org.slf4j.*</wls:package-name>
<wls:package-name>org.joda.*</wls:package-name>
<wls:package-name>com.fasterxml.*</wls:package-name>
</wls:prefer-application-packages>
I got hibernate weblogic "org.eclipse.persistence.jpa.PersistenceProvider cannot be cast to javax.persistence.spi.PersistenceProvider" exception from validator.
How can I solve this? (upgrade weblogic is not an option)
Thanks
I had same issue with Spring Boot and WebLogic 12c with error
org.eclipse.persistence.jpa.PersistenceProvider cannot be cast to javax.persistence.spi.PersistenceProvider
I was getting this error only if I was using any of validation annotations.
Solved by adding this to weblogic.xml:
<prefer-application-resources>
<resource-name>META-INF/services/javax.persistence.spi.PersistenceProvider</resource-name>
</prefer-application-resources>
Sorry for my late answer. My final solution:
add weblogic.xml into your war with these content:
<?xml version="1.0" encoding="UTF-8"?>
<wls:weblogic-web-app
xmlns:wls="http://xmlns.oracle.com/weblogic/weblogic-web-app"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee
http://java.sun.com/xml/ns/javaee/ejb-jar_3_0.xsd
http://xmlns.oracle.com/weblogic/weblogic-web-app
http://xmlns.oracle.com/weblogic/weblogic-web-app/1.4/weblogic-web-app.xsd">
<wls:container-descriptor>
<wls:prefer-web-inf-classes>true</wls:prefer-web-inf-classes>
</wls:container-descriptor>
</wls:weblogic-web-app>
Create ear (It's important) and add weblogic-application.xml:
<?xml version="1.0" encoding="UTF-8"?>
<weblogic-application xmlns="http://xmlns.oracle.com/weblogic/weblogic-application"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://xmlns.oracle.com/weblogic/weblogic-application
http://xmlns.oracle.com/weblogic/weblogic-application/1.4/weblogic-application.xsd">
<prefer-application-packages>
<package-name>org.slf4j.*</package-name>
<package-name>com.fasterxml.*</package-name>
<package-name>org.joda.*</package-name>
<package-name>org.hibernate.*</package-name>
<package-name>org.jboss.*</package-name>
<package-name>javax.validation.*</package-name>
</prefer-application-packages>
</weblogic-application>
This is work for me...
Obviously, there is a classloading conflict between the API and the implementation (eclipse.jpa.PersistenceProvider).
However, the reason for such conflict is yet to explain, since the 'prefer-application-packages' is supposed to tell the container to use what comes within the application package (i.e. both the API and implementation).
A workaround that worked for me in WLS 12.2.1 is as follows :
Exclude the dependency to the JAP2 API :
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-jpa</artifactId>
<exclusions>
<exclusion>
<groupId>org.hibernate.javax.persistence</groupId>
<artifactId>hibernate-jpa-2.1-api</artifactId>
</exclusion>
</exclusions>
</dependency>
Make sure your the 'prefer-application-packages' in weblogic.xml does not include javax.persistence.* (but should include javax.validation.* and org.hibernate.*)
Using this workaround, you are relying on the JPA2 implementation of the container..
Beware, thought, that this might be confusing if versions are different since behaviour might differ between unit tests (using JPA2 implementation that comes with Spring Boot : hibernate-jpa) and tests in container (using whatever JPA implementation WebLogic provides: likely eclipse JPA Provider).
A bit too late to answer you question I guess but it sounds like you are using a new interface and old implementation. This happens sometimes when you deploy to a container and not using class-path filtering for instance. In turn you will use an older implementation provided by the container. The behavior is very random depending on what gets loaded when. Hope this helps you in right direction or anyone else having similar problem.

Websphere 7 with JSF 2

I need to use JSF 2 for an application running under Websphere 7.0.0.13, I have followed this:
http://www.manorrock.com/online/wiki/app/page/edit.html
***It says:
Even though Websphere 7 does not formally support JSF 2.0 you can get it to work in a degraded mode. Follow the steps below to get it to work on your version of Websphere 7.
Upgrade to at least version 7.0.0.13
Ship the Mojarra JAR files in your WEB-INF/lib directory
Set the WAR classloader to PARENT_LAST
Set the EAR classloader to PARENT_LAST and APPLICATION
Note the degraded mode means you are NOT going to be able to use #Resource or any JPA annotations. If you think you need support for it contact your IBM representative.
Note it will process #PostConstruct and #PreDestroy.***
I did this, but I getting this error, in the log:
[8/30/13 22:51:32:702 CDT] 0000000c webapp E com.ibm.ws.webcontainer.webapp.WebApp notifyServletContextCreated SRVE0283E: Exception caught while initializing context: {0}
java.lang.LinkageError: loading constraint violation: loader "com/ibm/ws/classloader/CompoundClassLoader#31c031c" previously initiated loading for a different type with name "javax/servlet/ServletContext" defined by loader "org/eclipse/osgi/internal/baseadaptor/DefaultClassLoader#66656665"
at com.sun.faces.config.WebConfiguration.getInstance(WebConfiguration.java:184)
at com.sun.faces.config.ConfigureListener.contextInitialized(ConfigureListener.java:163)
at com.ibm.ws.webcontainer.webapp.WebApp.notifyServletContextCreated(WebApp.java:1681)
at com.ibm.ws.webcontainer.webapp.WebApp.commonInitializationFinish(WebApp.java:374)
at com.ibm.ws.webcontainer.webapp.WebAppImpl.initialize(WebAppImpl.java:299)
at com.ibm.ws.webcontainer.webapp.WebGroupImpl.addWebApplication(WebGroupImpl.java:100
And the error en my page:
Error 404: javax.servlet.UnavailableException: SRVE0201E: Servlet [javax.faces.webapp.FacesServlet]: not a servlet class
This is my web.xml
<?xml version="1.0" encoding="UTF-8"?>
<web-app id="WebApp_ID" version="2.5" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd">
<display-name>testJSF2</display-name>
<welcome-file-list>
<welcome-file>index.jsp</welcome-file>
</welcome-file-list>
<servlet>
<servlet-name>Faces Servlet</servlet-name>
<servlet-class>javax.faces.webapp.FacesServlet</servlet-class>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>Faces Servlet</servlet-name>
<url-pattern>*.faces</url-pattern>
</servlet-mapping>
<servlet-mapping>
<servlet-name>Faces Servlet</servlet-name>
<url-pattern>*.jsf</url-pattern>
</servlet-mapping>
</web-app>
I accesed by:
..../testJSF2/index.faces
If I enter by:
..../testJSF2/index.jsp
get this in the page:
HTTP Error Code: 500
Error Message:
JSPG0049E: /index.jsp failed to compile :
/opt/IBM/WebSphere/AppServer/profiles/AppSrv01/temp/wasccNode01/server4/testJSF2EAR/testJSF2.war/_index.java : 48 : The method getJspApplicationContext(ServletContext) is undefined for the type JspFactory
/opt/IBM/WebSphere/AppServer/profiles/AppSrv01/temp/wasccNode01/server4/testJSF2EAR/testJSF2.war/_index.java : 100 : The method handlePageException(Exception) in the type PageContext is not applicable for the arguments (Throwable)
JSPG0091E: An error occurred at line: 20 in the file: /index.jsp
JSPG0093E: Generated servlet error from file: /index.jsp
/opt/IBM/WebSphere/AppServer/profiles/AppSrv01/temp/wasccNode01/server4/testJSF2EAR/testJSF2.war/_index.java : 119 : The method getELContext() is undefined for the type PageContext
JSPG0091E: An error occurred at line: 21 in the file: /index.jsp
JSPG0093E: Generated servlet error from file: /index.jsp
/opt/IBM/WebSphere/AppServer/profiles/AppSrv01/temp/wasccNode01/server4/testJSF2EAR/testJSF2.war/_index.java : 144 : The method getELContext() is undefined for the type PageContext
Root Cause:
com.ibm.ws.jsp.JspCoreException: JSPG0049E: /index.jsp failed to compile :
/opt/IBM/WebSphere/AppServer/profiles/AppSrv01/temp/wasccNode01/server4/testJSF2EAR/testJSF2.war/_index.java : 48 : The method getJspApplicationContext(ServletContext) is undefined for the type JspFactory
/opt/IBM/WebSphere/AppServer/profiles/AppSrv01/temp/wasccNode01/server4/testJSF2EAR/testJSF2.war/_index.java : 100 : The method handlePageException(Exception) in the type PageContext is not applicable for the arguments (Throwable)
JSPG0091E: An error occurred at line: 20 in the file: /index.jsp
JSPG0093E: Generated servlet error from file: /index.jsp
/opt/IBM/WebSphere/AppServer/profiles/AppSrv01/temp/wasccNode01/server4/testJSF2EAR/testJSF2.war/_index.java : 119 : The method getELContext() is undefined for the type PageContext
JSPG0091E: An error occurred at line: 21 in the file: /index.jsp
JSPG0093E: Generated servlet error from file: /index.jsp
/opt/IBM/WebSphere/AppServer/profiles/AppSrv01/temp/wasccNode01/server4/testJSF2EAR/testJSF2.war/_index.java : 144 : The method getELContext() is undefined for the type PageContext
at com.ibm.ws.jsp.webcontainerext.AbstractJSPExtensionServletWrapper.translateJsp(AbstractJSPExtensionServletWrapper.java:574)
at com.ibm.ws.jsp.webcontainerext.AbstractJSPExtensionServletWrapper._checkForTranslation(AbstractJSPExtensionServletWrapper.java:441)
at com.ibm.ws.jsp.webcontainerext.AbstractJSPExtensionServletWrapper.checkForTranslation(AbstractJSPExtensionServletWrapper.java:299)
at com.ibm.ws.jsp.webcontainerext.AbstractJSPExtensionServletWrapper.handleRequest(AbstractJSPExtensionServletWrapper.java:149)
at com.ibm.ws.webcontainer.webapp.WebApp.handleRequest(WebApp.java:3826)
at com.ibm.ws.webcontainer.webapp.WebGroup.handleRequest(WebGroup.java:276)
at com.ibm.ws.webcontainer.WebContainer.handleRequest(WebContainer.java:931)
Thanks for you help.
For WebSphere 7, I've followed another article:
http://wasbehindtheglass.blogspot.co.uk/2011/11/myfaces-20-and-websphere-application.html
I've created shared library on WebSphere (name is not important, only content) with following jars:
manifest.jar
myfaces-api-2.0.7.jar
myfaces-impl-2.0.7.jar
commons-logging-1.1.1.jar
commons-digester-1.8.jar
commons-collections-3.2.jar
commons-codec-1.3.jar
commons-beanutils-1.8.3.jar
\IBM\SDP\runtimes\base_v7\optionalLibraries\IBM\JSFProviders\WebSphere-MyFaces20-annotation-provider.jar
You need to give absolute paths. WebSphere-MyFaces20-annotation-provider.jar should be in your WebSphere installation. manifest.jar is the jar containing only following META-INF/MANIFEST.MF:
Manifest-Version: 1.0
Extension-Name: org/apache/myfaces
Specification-Title: MyFaces 2.0.7 shared lib
Specification-Version: 1.0
Specification-Vendor: apache.org
Implementation-Version: 1.0
Final thing to be done is to modify your pom.xml to create the manifest entries referring the shared library:
<manifestEntries>
<Extension-List>myfaces</Extension-List>
<myfaces-Extension-Name>org/apache/myfaces</myfaces-Extension-Name>
<myfaces-Specification-Version>1.0</myfaces-Specification-Version>
</manifestEntries>
After the deploy, if both shared library and manifest are configured correctly, the binding is automatically created.
I'd guess you are not only providing the JSF classes, but a second instance / api as well.
Check if you have a servlet-api or something similar in your WEB-INF/lib folder.
As it cannot load the ServletContext you get the other follow-up errors. Probably even loading a simple jsp with no JSF in it fails.
I tried this, and it is working, just put here an alternative solution for future questions
this issue happen because we have add the servlet-api-2.5.jar in the project lib so when we remove it work .
so here the final Step to get this work
1- set the Parent last in the class loading policy for the application and module as well .
2- don't add the servlet-api-2.5 .jar to the porject lib
taked from here
https://www.ibm.com/developerworks/community/forums/html/topic?id=77777777-0000-0000-0000-000014541986
C:\apache-tomcat-8.0.3\webapps\kumar-app\WEB-INF\lib\servlet-api-2.3.jar
C:\apache-tomcat-8.0.3\lib\servlet-api.jar
I had above jar file version mismatch , i deleted the jar from C:\apache-tomcat-8.0.3\webapps\kumar-app\WEB-INF\lib\servlet-api-2.3.jar and my application worked properly.

Spring configuration for CXF WebService got java.lang.NoClassDefFoundError: javax/xml/ws/EndpointReference

I'm trying to get CXF to work with spring, maven on weblogic.the project compile/build fine, but when I try to deploy it I got this error:
<User defined listener org.springframework.web.context.ContextLoaderListener failed: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'ibanInfos': Initialization of bean failed; nested exception is java.lang.NoClassDefFoundError: javax/xml/ws/EndpointReference.
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'ibanInfos': Initialization of bean failed; nested exception is java.lang.NoClassDefFoundError: javax/xml/ws/EndpointReference
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:527)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:456)
at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:291)
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:222)
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:288)
Truncated. see log file for complete stacktrace
java.lang.NoClassDefFoundError: javax/xml/ws/EndpointReference
at java.lang.Class.getDeclaredMethods0(Native Method)
at java.lang.Class.privateGetDeclaredMethods(Class.java:2395)
at java.lang.Class.getDeclaredMethods(Class.java:1763)
at java.beans.Introspector$1.run(Introspector.java:1265)
at java.security.AccessController.doPrivileged(Native Method)
Any idea how to solve this?
In fact, I'm using the java first strategy to generate WSDL.
Here is my spring file :
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:jaxws="http://cxf.apache.org/jaxws"
xsi:schemaLocation="
http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans.xsd
http://cxf.apache.org/jaxws http://cxf.apache.org/schemas/jaxws.xsd">
<import resource="classpath:META-INF/cxf/cxf.xml" />
<import resource="classpath:META-INF/cxf/cxf-servlet.xml" />
<import resource="classpath:service-definition-beans.xml"/>
<jaxws:endpoint id="ibanInfos" implementor="#ibanInfosService" address="http://localhost:7001/IbanInfos" />
</beans>
Make sure you have jaxws-api-2.3.1.jar in your classpath.
It can be download via the above link or from maven.
<dependency>
<groupId>javax.xml.ws</groupId>
<artifactId>jaxws-api</artifactId>
<version>2.3.1</version>
</dependency>
I finally found the problem : im actually using weblogic under 10.0 version which provide Jaxws2.0 that doest contain EndPointInterface.
A workaroud is to add the jar into setDomainEnv.sh and it will work perfectly. Thanks alot for your answers.
EndpointReference was introduced in JAX-WS 2.1, and JAX-WS 2.1 is included into JRE since Java 1.6.0_04.
So, if EndpointReference is unavailable in your environment you need to upgrade your JRE/JDK, or include a recent version JAX-WS API as a separate dependency.
Seems like this class is not in your classpath. You should add the relevant item to your POM.
From searching the web, this class is present in many libraries. Here is an excerpt for including such aritfact:
<dependency>
<groupId>javax.xml.ws</groupId>
<artifactId>jaxws-api</artifactId>
<version>2.2.3</version>
</dependency>
Looks like you are using higher version of java, for an application which is not compatible to it yet.
If you are building the app in Intellij, try changing the jdk setup to java11 or java8, this would fix the issue.

Categories