I am running into some issues with trying to load libs from my application instead of what comes with JBoss.
I am trying to make use of the latest and greatest SLF4J in my application and in doing so I am getting the following messages:
SLF4J: Class path contains multiple SLF4J bindings.
SLF4J: Found binding in [vfszip:/C:/devtools/workspace/g2/.metadata/.plugins/org.jboss.ide.eclipse.as.core/JBoss_5.1_Runtime_Server1302541739184/deploy/ecotrakEar.ear/ecotrak.war/WEB-INF/lib/slf4j-log4j12-1.6.1.jar/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: Found binding in [vfszip:/C:/devtools/jboss-5.1.0.GA/common/lib/slf4j-jboss-logging.jar/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: See http://www.slf4j.org/codes.html#multiple_bindings for an explanation.
In my application I have the following jars located in my WAR lib directory:
jul-to-slf4j-1.6.1.jar
slf4j-api-1.6.1.jar
slf4j-log4j12-1.6.1.jar
My project is deployed as an EAR with a WAR. All libraries reside in the WAR.
Based on some research it has been suggested that for JBoss 5.1 that a jboss-classloading.xml file be created. I have created one for my EAR:
<classloading xmlns="urn:jboss:classloading:1.0"
name="ecotrak.ear"
domain="ecotrak.ear"
export-all="NON_EMPTY"
import-all="true"
parent-first="false">
</classloading>
This identifies that the EAR file is to be loaded first.
I have also created one for my WAR:
<classloading xmlns="urn:jboss:classloading:1.0"
name="ecotrak.war"
domain="ecotrak.war"
parent-domain="ecotrak.ear"
top-level-classloader="true"
export-all="NON_EMPTY"
import-all="true"
parent-first="true">
</classloading>
With this configuration I am getting the following error in the startup logs:
11:18:07,949 ERROR [[/ecotrak]] Exception sending context initialized event to listener instance of class org.springframework.web.context.ContextLoaderListener
java.lang.NoSuchMethodError: org.slf4j.spi.LocationAwareLogger.log(Lorg/slf4j/Marker;Ljava/lang/String;ILjava/lang/String;[Ljava/lang/Object;Ljava/lang/Throwable;)V
at org.apache.commons.logging.impl.SLF4JLocationAwareLog.trace(SLF4JLocationAwareLog.java:107)
What is the correct way in order to have jars from my project be loaded before JBoss's?
You should use something like as:
<jboss-app>
<loader-repository>
com.example:archive=unique-archive-name
</loader-repository>
</jboss-app>
in META-INF/jboss-app.xml to define own classloader.
We use it for own Hibernate jars deployement inside application.
See https://community.jboss.org/wiki/ClassLoadingConfiguration for details
I know this thread is very old, but I had a similar problem today so I think the problem itself may happen yet with someone.
I needed to run two similar 'ear' in different contexts, with the same package/class names inside its subprojects (JBoss 5.1.0 GA).
So after some research, and attempts to use the full 'jboss-classloading.xml' version provided here and by some blogs, I used a simpler version of 'jboss-classloading.xml' file on my EAR (with no specific 'jboss-classloading.xml' for my subprojects JAR/WAR/etc.):
<classloading xmlns="urn:jboss:classloading:1.0"
domain="IsolatedDomain"
export-all="NON_EMPTY"
import-all="true">
</classloading>
This was included in my EAR project META-INF directory. Hope this helps others with similar problems.
I got the working version from this site:
https://access.redhat.com/documentation/en-US/JBoss_Enterprise_Application_Platform/5/html/Microcontainer_User_Guide/sect-JBoss_Microcontainer_User_Guide-The_ClassLoading_Layer-ClassLoading.html
Related
We have an application which we're trying to get to run on WebLogic 12.2.1.3.0 but even though we have the correct spring-aop-3.0.2.RELEASE.jar in the application's web-inf\lib directory we still get a
weblogic.application.ModuleException: java.lang.RuntimeException: java.lang.ClassNotFoundException: org.springframework.aop.framework.AopConfigException
I have tried adding <prefer-application-packages> for packagename org.springframework.* to the weblogic.xml and weblogic-application.xml and also setting <prefer-web-inf-classes>true</prefer-web-inf-classes> but I cant' seem to get around this.
Any ideas?
You should add
<package-name>net.sf.cglib.*</package-name>
to
<prefer-application-packages> in your weblogic-application.xml to enable WebLogic to load cglib from your application classpath.
I am trying out the following tutorial which creates a simple EJB and then accesses via a Java SE client:
http://www.tutorialspoint.com/ejb/ejb_create_application.htm
This tutorial uses ant but I am using maven. Now, in my client, I am getting the following error while creating the initial context:
javax.naming.NoInitialContextException: Cannot instantiate class:
org.jnp.interfaces.NamingContextFactory [Root exception is java.lang.ClassNotFoundException:
org.jnp.interfaces.NamingContextFactory]
at javax.naming.spi.NamingManager.getInitialContext(NamingManager.java:674)
at javax.naming.InitialContext.getDefaultInitCtx(InitialContext.java:307)
at javax.naming.InitialContext.init(InitialContext.java:242)
at javax.naming.InitialContext.<init>(InitialContext.java:216)
at EJBDriver.main(EJBDriver.java:21)
I have added the following dependencies to my pom.xml:
<groupId>org.jboss.spec</groupId>
<artifactId>jboss-javaee-6.0</artifactId>
<groupId>org.jboss.as</groupId>
<artifactId>jboss-as-ejb-client-bom</artifactId>
Finally, the jndi properties:
java.naming.factory.initial=org.jnp.interfaces.NamingContextFactory
java.naming.factory.url.pkgs=org.jboss.naming:org.jnp.interfaces
java.naming.provider.url=localhost:4447
How to solve this issue?
I solved the problem as follows
1- If the EJB classes are in different projects, than the project with EJB classes needs to be added to the classpath of the project containing the client. For Eclipse:
Right Click on project->Build Path->Configure Build Path-> Projects tab->Add->Select the desired project->OK->OK
2- The jboss-client.jar file needs to be added to the class path of the EJB client project as well.
Right Click on project->Build Path->Configure Build Path-> Projects tab->Librariers->Add External JAR
Browse to the jboss-client.jar file(In windows its located in JBoss_Installation/bin/client)
Select the file and click OK twice.
jboss 6 should use the following properties:
naming factory= org.jboss.naming.remote.client.InitialContextFactory
provider url= remote://localhost:4447
when i deploy my first web app on webLogic i get this error:
weblogic.application.ModuleException: java.lang.NullPointerException
at weblogic.application.internal.ExtensibleModuleWrapper.prepare(ExtensibleModuleWrapper.java:114)
at weblogic.application.internal.flow.ModuleListenerInvoker.prepare(ModuleListenerInvoker.java:100)
at weblogic.application.internal.flow.ModuleStateDriver$1.next(ModuleStateDriver.java:172)
at weblogic.application.internal.flow.ModuleStateDriver$1.next(ModuleStateDriver.java:167)
at weblogic.application.utils.StateMachineDriver$ParallelChange.run(StateMachineDriver.java:80)
Truncated. see log file for complete stacktrace
Caused By: java.lang.NullPointerException
at weblogic.servlet.internal.WebAnnotationProcessor.processMultipartConfigAnnotation(WebAnnotationProcessor.java:286)
at weblogic.servlet.internal.AnnotationProcessingManager.processAnnotationForClasses(AnnotationProcessingManager.java:169)
at weblogic.servlet.internal.AnnotationProcessingManager.processAnnotations(AnnotationProcessingManager.java:114)
at weblogic.servlet.internal.AnnotationProcessingManager.processAnnotationsOutsideWebFragment(AnnotationProcessingManager.java:141)
at weblogic.servlet.internal.AnnotationProcessingManager.processAnnotations(AnnotationProcessingManager.java:102)
Truncated. see log file for complete stacktrace
I had this problem and resolved it by removing JSF 2.2 Mojarra 2.2.0 from the application libraries. It only needs to be in the classpath.
In Eclipse, edit properties for the project, go to Project Facets-->Java Server Faces and uncheck "Include libraries with this application" and Apply change.
I deploy from Eclipse (OEPE), same problem here without JSF. Here is what solved my problem:
Quit Eclipse
Delete the workspace's .metadata folder
Launch Eclipse
The same solution worked on NetBeans8. From projects, go to your war project, right click over Libraries > JSF2.2 and click Remove. Rebuild the project and deploy. Remember to deploy as shared library the JSF on WLS.
This seems to be a duplicate of Maven generated ear file fails during deploying weblogic server. Some details about the solution can be found in this post https://roundwheeltech.wordpress.com/2016/06/15/deploying-a-jsf-2-2-to-weblogic-12-1-3/.
Because WebLogic 12.1.3 ships with JSF 2.1, the required JSF jars have to be bundles within the WAR file (specified as dependencies in pom.xml). WebLogic must also be instructed to use the libraries packaged in the WAR file instead of the ones that are provided by the container.
I had the exact same NPE. It was started by an instantiation of an factory that went wrong. I had to remote debug in to find this. An exception in the initialisation of the factory is swallowed and we don't get the real exception.
In my case the problem was antlr.Token and antlr.CommonToken not arriving from the same source. This gave me an ClassCastException. I solved it by moving all libraries from the ear to war to get more control over them.
Edit the file web.xml and put:
<welcome-file-list>
<welcome-file>faces/index.xhtml</welcome-file>
</welcome-file-list>
<servlet-mapping>
<servlet-name>Faces Servlet</servlet-name>
<url-pattern>/faces/*</url-pattern>
</servlet-mapping>
I am using eclipse indigo to run my tomcat server, when I am launching tomcat server, the tomcat server successfully up and running, but with error shown in the console.
ERROR - ContextLoader[177]: Context initialization failed
org.springframework.beans.factory.BeanDefinitionStoreException: Error registering bean with name 'com.huahsin68.MyBoc' defined in class path resource [my-spring.xml]: Class that bean class [com.huahsin68.MyBocImp] depends on not found; nested exception is java.lang.NoClassDefFoundError: javax/mail/MessagingException
java.lang.NoClassDefFoundError: javax/mail/MessagingException
It seems like the MessagingException wasn't found. I have check in the Java Build Path > Libraries, I notice that javax.mail_1.4.0.v200105080615.jar was there. This jar file is locate under eclipse > plugins folder. Is there anything solution to rectify this problem?
THanks #!
With Maven, you can add the following dependency:
<dependency>
<groupId>javax.mail</groupId>
<artifactId>mail</artifactId>
<version>1.4.5</version>
</dependency>
Try the following:
Download the java mail jars from: http://www.oracle.com/technetwork/java/javamail/index-138643.html
Add the jars to your WEB-INF/lib folder
Add the jars to Java Build Path > Libraries
That should do it.
For gradle/android users, in build.gradle (Module app):
compile 'javax.mail:mail:1.4.1'
I had a similar problem, running tomcat stand-alone (that is, not through Eclipse). I copied mail-1.4.jar to my tomcat/lib directory. This worked for me.
For those conning late in this ..
I got the same error resolved by adding below jar.
geronimo-javamail_1.4_mail-1.8.3.jar
As part of an upgrade from JBoss 4.0.4 to 5.1, I am trying to get a WAR to deploy after an EAR is successfully deployed. JBoss 5.x does not support PrefixDeploymentSorter like 4.x did, which means that I have to use <depends> in the WAR's jboss-web.xml.
It seems I cannot depend on the EAR itself, so I pick the last deployed EJB instead. This EJB provides a JNDI entry that the WAR needs.
Here's the EJB as it deploys when the WAR is absent from the deploy directory:
2010-03-25 10:47:30,348 INFO [org.jboss.ejb3.session.SessionSpecContainer] (main) Starting jboss.j2ee:ear=my-ear.ear,jar=mypackage-ejb.jar,name=MyFacadeBean,service=EJB3
2010-03-25 10:47:30,350 INFO [org.jboss.ejb3.EJBContainer] (main) STARTED EJB: my.package.MyFacadeBean ejbName: MyFacadeBean
2010-03-25 10:47:30,371 INFO [org.jboss.ejb3.proxy.impl.jndiregistrar.JndiSessionRegistrarBase] (main) Binding the following Entries in Global JNDI:
my/MyFacade/local - EJB3.x Default Local Business Interface
my-ear/MyFacadeBean/local-my.package.MyFacade - EJB3.x Local Business Interface
And here's the depends snippet from jboss-web.xml:
<depends>jboss.j2ee:ear=my-ear.ear,jar=mypackage-ejb.jar,name=MyFacadeBean,service=EJB3</depends>
My problem is: The WAR starts to deploy immediately after "STARTED EJB:", i.e. before MyFacadeBean is bound to JNDI, which causes bean deployments to fail:
2010-03-25 10:47:39,068 ERROR [my.facade.FacadeFactory] (main) MyFacade not bound
2010-03-25 10:47:39,069 ERROR [org.apache.catalina.core.ContainerBase.[jboss.web].[my.host.no].[/]] (main) StandardWrapper.Throwable
java.lang.ExceptionInInitializerError
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:164)
at my.freemarker.servlet.FreemarkerController.setupPojoServiceFactory(FreemarkerController.java:621)
[...]
Caused by: java.lang.RuntimeException: javax.naming.NameNotFoundException: MyFacade not bound
at my.facade.FacadeFactory.getFacade(FacadeFactory.java:61)
After the WAR has finished its deployment, MyFacade happily (mockingly?) continues its deployment and binds the JNDI entries.
If I hot-deploy the WAR after the EAR has deployed, everything works as intended.
I even thought of depending on a dummy EJB in the EAR, and using <module-order>strict</module-order> in jboss-app.xml to force it to load as the last module. But alas, JBoss 5.x does not support that either. Doh!
Is there a way to depend on the JNDI entry itself? Are there other ways of solving this?
Here's how you can achieve this on JBoss 5.1.x.
First, add a file called aliases.txt into the META-INF directory of your EAR. This file should just contain a single line with an arbitrary name / identifier for your EAR. For example, if you have my-ear.ear, your META-INF/aliases.txt file could contain 'my-ear'. It just needs to be something that won't clash with any other aliases declared by other apps deployed on the same server.
Next, add a jboss-dependency.xml file to the META-INF directory of your WAR, containing the following (subsituting 'my-ear' for the alias you created above):
<dependency xmlns="urn:jboss:dependency:1.0">
<item whenRequired="Real" dependentState="Create">my-ear</item>
</dependency>
This will ensure the EAR is deployed before the WAR.
Also, if you try to deploy the WAR without the EAR being present, JBoss will log a clear deployment error message telling you about the missing dependency.