WELD-001201: Error loading beans.xml + Tomcat 7.0.59 - java

I have one application using CDI with weld 2.2.9.Final and embedded Tomcat 7.0.57 and everything works fine.
After upgrading to embedded Tomcat 7.0.59, when I'm starting my application I got the following exception:
Caused by: org.jboss.weld.exceptions.IllegalStateException: WELD-001201: Error loading beans.xml jndi:/localhost/WEB-INF/beans.xml
at org.jboss.weld.xml.BeansXmlParser.parse(BeansXmlParser.java:124)
at org.jboss.weld.bootstrap.WeldBootstrap.parse(WeldBootstrap.java:131)
at org.jboss.weld.environment.servlet.deployment.WebAppBeanArchiveScanner.scan(WebAppBeanArchiveScanner.java:78)
at org.jboss.weld.environment.deployment.discovery.AbstractDiscoveryStrategy.performDiscovery(AbstractDiscoveryStrategy.java:83)
at org.jboss.weld.environment.servlet.WeldServletLifecycle.createDeployment(WeldServletLifecycle.java:230)
at org.jboss.weld.environment.servlet.WeldServletLifecycle.initialize(WeldServletLifecycle.java:120)
at org.jboss.weld.environment.servlet.EnhancedListener.onStartup(EnhancedListener.java:61)
at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5513)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
... 6 more
Caused by: java.io.FileNotFoundException: jndi:/localhost/WEB-INF/beans.xml
at org.apache.naming.resources.DirContextURLConnection.getInputStream(DirContextURLConnection.java:384)
at java.net.URL.openStream(URL.java:1037)
at org.jboss.weld.xml.BeansXmlParser.parse(BeansXmlParser.java:101)
... 14 more

The problem is java.io.FileNotFoundException: jndi:/localhost/WEB-INF/beans.xml
I just bumped into something similar today. Either the file can't be found, or you are trying to include it from your web.xml with an ENTITY declaration. If you are trying to load beans.xml with an ENTITY declaration, then the problem is caused by a new security policy in Tomcat 7.0.59 -- blocking the loading of external entities is now the default. Context parameter xmlBlockExternal is now set to "true" by default.
You have to override this in a your context: either the main context in ~Tomcat/conf/context.xml or in your application-level context file. To override, add the param like this:
<Context xmlBlockExternal="false">

Related

Deploying spring application in wildfly 11 result in " Only one AsyncAnnotationBeanPostProcessor may exist within the context." error

We have a Java Spring 3.2 project, we are trying to migrate the project from jBoss 7 to wildFly 11
However, during the deployment the following error occurs:
Cannot upload deployment: {"WFLYCTL0080: Failed services" => {"jboss.undertow.deployment.default-server.default-host./faultmanager" =>
"java.lang.RuntimeException: org.springframework.beans.factory.parsing.BeanDefinitionParsingException: Configuration problem:
Only one AsyncAnnotationBeanPostProcessor may exist within the context. Offending resource:
\"/D:/wildfly-11.0.0.Final/wildfly-11.0.0.Final/bin/content/xxxx.war/WEB-INF/classes/META-INF/spring/applicationContext.xml\"
Caused by: java.lang.RuntimeException: org.springframework.beans.factory.parsing.BeanDefinitionParsingException:
Configuration problem: Only one AsyncAnnotationBeanPostProcessor may exist within the context. Offending resource:
\"/D:/wildfly-11.0.0.Final/wildfly-11.0.0.Final/bin/content/xxxxxx.war/WEB-INF/classes/META-INF/spring/applicationContext.xml\"
Caused by: org.springframework.beans.factory.parsing.BeanDefinitionParsingException: Configuration problem:
Only one AsyncAnnotationBeanPostProcessor may exist within the context. Offending resource:
\"/D:/wildfly-11.0.0.Final/wildfly-11.0.0.Final/bin/content/xxxxxx.war/WEB-INF/classes/META-INF/spring/applicationContext.xml\""}}
With our attempts and our searches, we got that the exception could be throwed by some causes:
Some bean in applicationContext.xml is defined twice
The applicationContext.xml is imported twice
Some bean defined in applcationContext.xml is defined again in a different file
This may be caused by a tag defined in applicationElement.xml, but trying to remove it will cause a illegalArgumentException during the deploy (don't know why), interestingly this doesn't appear to be used anywhere
This may be caused by another contextl (we have an applicationContext-security) but even removing it the same error above will persist
Others fun facts:
The error is never throwned during the build, only during the deploy throught wildFly
The same project have worked for year in jboss without this kind of problem
What could be the cause?
this will happens only ,
1)may be you are import both applicationContext-root.xml and applicationContext-where-annotation-driven-is-specififed.xml in your WEB.xml in section.
2)make applicationContext-root.xml in WEB.xml.
2)This is happenning because you are initializ The application context twice but org.springframework.scheduling.config.AnnotationDrivenBeanDefinitionParser fails registering bean ASYNC_ANNOTATION_PROCESSOR_BEAN_NAME second time.
3)and spring parses the <task:annotation-driven/> text twice in a config XML.
may be one of the resons is that #ContextConfiguration("/path/to/applicationContext.xml") are both the parent test class and child test class

Spring Boot JNDI CommonJ resource

Trying to get WorkManagers working with CommonJ in a Spring Boot app, hosted in TomEE.
Currently have the following configuration:
Tomcat context.xml
<Context>
<Resource name="myWorkManager"
auth="Container"
type="commonj.work.WorkManager"
factory="de.myfoo.commonj.work.FooWorkManagerFactory"
maxThreads="5" />
<ResourceLink
name="myWorkManager"
global="myWorkManager"
type="commonj.work.WorkManager" />
</Context>
Spring app web.xml
<resource-ref>
<res-ref-name>myWorkManager</res-ref-name>
<res-type>commonj.work.WorkManager</res-type>
<res-auth>Container</res-auth>
</resource-ref>
This is currently throwing the following exception when the app loads:
Caused by: org.springframework.jndi.TypeMismatchNamingException: Object of type [class de.myfoo.commonj.work.FooWorkManager] available at JNDI location [java:comp/env/myWorkManager] is not assignable to [commonj.work.WorkManager]
at org.springframework.jndi.JndiTemplate.lookup(JndiTemplate.java:182)
at org.springframework.jndi.JndiLocatorSupport.lookup(JndiLocatorSupport.java:95)
at org.springframework.scheduling.commonj.WorkManagerTaskExecutor.afterPropertiesSet(WorkManagerTaskExecutor.java:110)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1637)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1574)
... 53 more
I have the CommonJ jars downloaded from http://commonj.myfoo.de/install.shtml in my Tomcat lib directory.
I feel like I'm getting pretty close but slightly puzzled by this exception.
Any help would be much appreciated.
UPDATE
If I remove the two CommonJ jars from TomEE lib folder, I get this exception
Caused by: java.lang.ClassNotFoundException: commonj.work.WorkManager
Which is what I would expect.
If I remove the factory property from the resource element I get:
Caused by: org.springframework.jndi.TypeMismatchNamingException:
Object of type [class org.apache.openejb.core.ivm.naming.IvmContext]
available at JNDI location [java:comp/env/wm/default] is not
assignable to [commonj.work.WorkManager]
Im encounter with same issue, when try to start my app locally in maven-jetty-plugin. M. Deinum comment was very helpful. This error happens if you have lib jar in shared lib of your Application Server and in your WEB-INF/lib folder of web application, because server use one jar to create resource (parent classloader), but application use self jar(child classloader) and it two different classes hierarchy, so FooWorkManager cant be cast to WorkManager.

<HTTP> <BEA-101163> <Could not load user defined listener:

I have modified an EAR for Weblogic 10 ( BEA 10 )which is already running on BEA 8..
I am getting the following error while deploying the EAR..
[HTTP:101163]Could not load user defined listener: com.xxx.xxxx.jmx.LifecycleListener java.lang.NoClassDefFoundError: com/tibco/sdk/MException at java.lang.Class.getDeclaredConstructors0(Native Method) at java.lang.Class.privateGetDeclaredConstructors(Class.java:2357) at java.lang.Class.getConstructor0(Class.java:2671) at java.lang.Class.newInstance0(Class.java:321) at java.lang.Class.newInstance(Class.java:303) at weblogic.servlet.internal.WebComponentContributor.getNewInstance(WebComponentContributor.java:187) at weblogic.servlet.internal.WebComponentContributor.createListenerInstance
Have you faced this error ?Please help me...
From the Exception it seems that some library is missing from your ear file. Make sure that com.xxx.xxxx.jmx.LifecycleListener is a valid package and included correctly in your ear.
If you are developing and building the ear with JDeveloper make sure you add this lib in your application resources. If you do this manualy make sure that this lib exists in your WEB-INF/lib folder

Netbeans generated WAR doesn't work in Glassfish Server 3.1

I've tried to deploy a Netbeans WAR webservice into Glassfish several times, but it returns this error:
Error occurred during deployment: Exception while loading the app :
java.lang.IllegalStateException: ContainerBase.addChild: start:
org.apache.catalina.LifecycleException: org.apache.catalina.LifecycleException:
javax.servlet.ServletException:
com.sun.xml.ws.transport.http.servlet.WSServletException:
WSSERVLET11: failed to parse
runtime descriptor: java.lang.RuntimeException: MASM0015: Class [
com.sun.xml.ws.tx.runtime.TxTubeFactory ] does not implement [
com.sun.xml.ws.assembler.dev.TubeFactory ] interface.
Please see server.log for more details.
Whatever WAR I generate in Eclipse works in Glassfish, but I tried importing from Netbeans this project, and it didn't work. Glassfish also returns this same error. The log doesn't extend the information of the possible problem.
By the way, in the embedded Glassfish for Netbeans, the webservice works like a charm, but importing this, results in an error in the Glassfish server (which is another computer)
Any suggestions? Is there any configuration I need to change in the Glassfish server?
Thank you all for your ideas and solutions.
Cristina
Extract from Server .LOG
[#|2012-05-31T10:16:59.951-
0430|INFO|glassfish3.1|com.sun.xml.ws.wstx|_ThreadID=40;_ThreadName=Thread-1;|[failed
to localize] HOST_AND_PORT_LOOKUP_FAILURE_2015(https://192.168.2.43:8080)
java.lang.ClassNotFoundException: com.sun.enterprise.webservice.WsTxUtils
[#|2012-05-31T10:16:59.990-
0430|SEVERE|glassfish3.1|com.sun.xml.ws.wspolicy.jaxws.PolicyWSDLParserExtension|_ThreadID= 40;_ThreadName=Thread-1;|WSP1007: Policy exception occured when finishing WSDL parsing.
com.sun.xml.ws.policy.PolicyException: [failed to localize]
WSP_0071_ERROR_MULTIPLE_ASSERTION_CREATORS_FOR_NAMESPACE(http://schemas.xmlsoap.org/ws/2004/08/addressing, com.sun.xml.ws.security.addressing.impl.policy.AddressingPolicyAssertionCreator, com.sun.xml.ws.addressing.impl.policy.AddressingPolicyAssertionCreator)
Caused by: com.sun.xml.ws.policy.PolicyException: [failed to localize] WSP_0071_ERROR_MULTIPLE_ASSERTION_CREATORS_FOR_NAMESPACE(http://schemas.xmlsoap.org/ws/2004 /08/addressing, com.sun.xml.ws.security.addressing.impl.policy.AddressingPolicyAssertionCreator, com.sun.xml.ws.addressing.impl.policy.AddressingPolicyAssertionCreator)
[#|2012-05-31T10:16:59.990- 0430|FINE|glassfish3.1|javax.enterprise.system.container.web.org.glassfish.web.loader|_Thre adID=143;_ThreadName=Thread- 1;ClassName=org.glassfish.web.loader.WebappClassLoader;MethodName=clearReferences;|Could not set field tm to null in class com.sun.xml.ws.tx.at.ATCoordinator
java.lang.NoClassDefFoundError: Could not initialize class com.sun.xml.ws.tx.at.ATCoordinator
[#|2012-05-31T10:16:59.990- 0430|FINE|glassfish3.1|javax.enterprise.system.container.web.org.glassfish.web.loader|_Thre adID=143;_ThreadName=Thread- 1;ClassName=org.glassfish.web.loader.WebappClassLoader;MethodName=clearReferences;|Could not set field wsatCoordinatorService to null in class com.sun.xml.ws.tx.at.ATCoordinator
java.lang.NoClassDefFoundError: Could not initialize class com.sun.xml.ws.tx.at.ATCoordinator
[#|2012-05-31T10:16:59.990- 0430|FINE|glassfish3.1|javax.enterprise.system.container.web.org.glassfish.web.loader|_Thre adID=143;_ThreadName=Thread- 1;ClassName=org.glassfish.web.loader.WebappClassLoader;MethodName=clearReferences;|Could not set field wsatCoordinatorService to null in class com.sun.xml.ws.tx.at.ATCoordinator
java.lang.NoClassDefFoundError: Could not initialize class com.sun.xml.ws.tx.at.ATCoordinator
Something similar happened to me recently. What happened was that initially I was going to deploy the application to Tomcat7, so Netbeans included some Metro jars in my library section. I then decided to deploy to Glassfish instead, however those Metro jars are what are apparently causing the problem you are seeing. I just deleted the Metro jars from my libraries section in Netbeans, redeployed, and everything was ok.
Here is a link that talks a little bit more about what is happening: https://java.net/jira/browse/WSIT-1636.

NoClassDefFoundError in spring

I wrote a Spring application which runs on Weblogic 10.3. In this application I have some JMS Queue consumers.
Sometimes I got an error when the application is closing or opening (I saw this error in both situation) saying:
java.lang.NoClassDefFoundError: org/springframework/jms/connection/SmartConnectionFactory
at org.springframework.jms.connection.ConnectionFactoryUtils.releaseConnection(ConnectionFactoryUtils.java:72)
at org.springframework.jms.listener.AbstractJmsListeningContainer.refreshSharedConnection(AbstractJmsListeningContainer.java:385)at org.springframework.jms.listener.DefaultMessageListenerContainer.refreshConnectionUntilSuccessful(DefaultMessageListenerContainer.java:779)
at org.springframework.jms.listener.DefaultMessageListenerContainer.recoverAfterListenerSetupFailure(DefaultMessageListenerContainer.java:761)
at org.springframework.jms.listener.DefaultMessageListenerContainer$AsyncMessageListenerInvoker.run(DefaultMessageListenerContainer.java:892)
at java.lang.Thread.run(Thread.java:619)
Caused by: java.lang.ClassNotFoundException: org.springframework.jms.connection.SmartConnectionFactory
at weblogic.utils.classloaders.GenericClassLoader.findLocalClass(GenericClassLoader.java:283)
at weblogic.utils.classloaders.GenericClassLoader.findClass(GenericClassLoader.java:256)
at weblogic.utils.classloaders.ChangeAwareClassLoader.findClass(ChangeAwareClassLoader.java:54)
at java.lang.ClassLoader.loadClass(ClassLoader.java:303)
at java.lang.ClassLoader.loadClass(ClassLoader.java:248)
at weblogic.utils.classloaders.GenericClassLoader.loadClass(GenericClassLoader.java:176)
at weblogic.utils.classloaders.ChangeAwareClassLoader.loadClass(ChangeAwareClassLoader.java:35)
at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:316)
... 6 more
Why do I get this error and what should I do to solve it?
The version of the spring.jar is 2.5.5
That Exception means that the class is not getting loaded into the JVM. Make sure that the spring.jar is in the Weblogic server's classpath or library folder.
It's all very well that you have this class in your war, but in Weblogic, the war has its own classloader. Since your stack trace shows a JMS listener, I'd ask: where is the listener? If it's in the war, then you have a mystery. But it sure looks as though it's somewhere else, and it's that somewhere else that would be missing this Spring class.

Categories

Resources