[Beginners Corner] - ClassNotFoundException in an ear application
by vamsin
This might be a fundamental question:
I have a singleton class: SpringContext in a jar: context.jar and is initialiazed by a InitServlet. This servlet is defined in web.xml and loaded from WEB-INF/classes. During init(ServletConfig..), the spring beans container is inited with few beans.
However, I have a jar that resides under myapp.ear directory which cannot access the ContextLoader class that was already inited during Servlet load time.
How can I successfully use it in a class defined in the jar under myapp.ear?
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
The actual error log is shown here:
2008-07-21 16:18:18,812 ERROR [org.apache.catalina.core.ContainerBase.[jboss.web].[localhost].[/myApp/xyz]]
Exception while dispatching incoming RPC call
com.google.gwt.user.server.rpc.UnexpectedException: Service method 'public abstract java.lang.String
com.mysoftware.myApp.gwt.client.MyImpl.getSpringBeanByName(java.lang.String,java.lang.String)'
threw an unexpected exception: java.lang.NoClassDefFoundError: com/mysoftware/myApp/InitServlet
at com.google.gwt.user.server.rpc.RPC.encodeResponseForFailure(RPC.java:361)
at com.google.gwt.user.server.rpc.RPC.invokeAndEncodeResponse(RPC.java:547)
at com.google.gwt.user.server.rpc.RemoteServiceServlet.processCall(RemoteServiceServlet.java:265)
at com.google.gwt.user.server.rpc.RemoteServiceServlet.doPost(RemoteServiceServlet.java:187)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:810)
...
at java.lang.Thread.run(Thread.java:619)
Caused by: java.lang.NoClassDefFoundError: com/mysoftware/myApp/InitServlet
at com.mysoftware.myApp.dao.ResourceHeaderDAO.loadHeaders(ResourceHeaderDAO.java:993)
at com.mysoftware.myApp.dao.ResourceHeaderDAO.loadAllHeaders(ResourceHeaderDAO.java:582)
at com.mysoftware.myApp.gwt.server.MyImpl.getSpringBeanByName(MyImpl.java:79)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at com.google.gwt.user.server.rpc.RPC.invokeAndEncodeResponse(RPC.java:528)
... 24 more
Caused by: java.lang.ClassNotFoundException: No ClassLoaders found for: com.mysoftware.myApp.MyServletContext
at org.jboss.mx.loading.LoadMgr3.beginLoadTask(LoadMgr3.java:292)
at org.jboss.mx.loading.RepositoryClassLoader.loadClassImpl(RepositoryClassLoader.java:475)
at org.jboss.mx.loading.RepositoryClassLoader.loadClass(RepositoryClassLoader.java:377)
at java.lang.ClassLoader.loadClass(ClassLoader.java:252)
at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:320)
... 32 more
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Thanks,
Vamsi
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4165749#4165749
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4165749
17 years, 10 months
[EJB 3.0] - Re: Session bean lookup fails JBoss 5, worked in 4.0.5
by lpmon
I have included excerpts from the log and JNDIView. I am still stuck on this problem.
I notice that:
1) The "added bean" message for DBUtilBean is 1st (with expected jndi name)
2) The Seam "welcome" message is next
3) The failed lookup is next (this is now in a servlet)
4) then I see: STARTED EJB: com.pearson.ejb3.session.DBUtilBean
If the SLSB must be started before it can be looked up then that explains the behavior. But, I do not know how to force ordering.
I have tried changing the order of the modules in application.xml with no success.
IMPORTANT: By changing from an @Startup Seam component to a startup servlet I was able to get my .jar and .war to deploy successfully. The startup method, servlet.init(), still fails when trying to lookup DBUtilBean but this change allows me to get the app up and running. Subsequent lookups using the same jndi name are successful! It looks like the jndi lookups fail unless the entire bootup process has totally completed. It is not a matter of using the correct jndi name or the latter lookup would fail too.
2008-07-21 14:49:27,741 INFO [org.jboss.ejb3.deployers.JBossASKernel] (main) Created KernelDeployment for: ec20.jar
....
2008-07-21 14:49:29,007 INFO [org.jboss.ejb3.deployers.JBossASKernel] (main) installing bean: jboss.j2ee:ear=ec20.ear,jar=ec20.jar,name=DBUtilBean,service=EJB3
2008-07-21 14:49:29,007 INFO [org.jboss.ejb3.deployers.JBossASKernel] (main) with dependencies:
2008-07-21 14:49:29,007 INFO [org.jboss.ejb3.deployers.JBossASKernel] (main) and demands:
2008-07-21 14:49:29,007 INFO [org.jboss.ejb3.deployers.JBossASKernel] (main) persistence.units:ear=ec20.ear,jar=ec20.jar,unitName=ec20
2008-07-21 14:49:29,022 INFO [org.jboss.ejb3.deployers.JBossASKernel] (main) jboss.ejb:service=EJBTimerService
2008-07-21 14:49:29,038 INFO [org.jboss.ejb3.deployers.JBossASKernel] (main) and supplies:
2008-07-21 14:49:29,038 INFO [org.jboss.ejb3.deployers.JBossASKernel] (main) jndi:ec20/DBUtilBean/local-com.pearson.ejb3.session.DBUtil
2008-07-21 14:49:29,038 INFO [org.jboss.ejb3.deployers.JBossASKernel] (main) jndi:ec20/DBUtilBean/local
2008-07-21 14:49:29,038 INFO [org.jboss.ejb3.deployers.JBossASKernel] (main) Class:com.pearson.ejb3.session.DBUtil
2008-07-21 14:49:29,038 INFO [org.jboss.ejb3.deployers.JBossASKernel] (main) jndi:DBUtilBean
2008-07-21 14:49:29,038 INFO [org.jboss.ejb3.deployers.JBossASKernel] (main) Added bean(jboss.j2ee:ear=ec20.ear,jar=ec20.jar,name=DBUtilBean,service=EJB3) to KernelDeploym
....
07-21 14:49:52,538 INFO [javax.servlet.ServletContextListener] (main) Welcome to Seam 2.0.3.CR1
....
2008-07-21 14:50:29,507 FATAL [com.pearson.util.LookupUtil] (main) for Interface: DBUtilBean context is null: false (my logging for the exception)
javax.naming.NameNotFoundException: ec20 not bound
at org.jnp.server.NamingServer.getBinding(NamingServer.java:542)
at org.jnp.server.NamingServer.getBinding(NamingServer.java:550)
at org.jnp.server.NamingServer.getObject(NamingServer.java:556)
at org.jnp.server.NamingServer.lookup(NamingServer.java:267)
at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:669)
at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:629)
at javax.naming.InitialContext.lookup(InitialContext.java:351)
at com.pearson.util.LookupUtil.lookupEJB(LookupUtil.java:61)
at com.pearson.servlet.StartupServlet.init(StartupServlet.java:51)
2008-07-21 14:51:17,851 INFO [org.jboss.ejb3.EJBContainer] (main) STARTED EJB: com.pearson.ejb3.session.DBUtilBean ejbName: DBUtilBean
Global JNDI Namespace
...
+- ec20 (class: org.jnp.interfaces.NamingContext)
| +- IButtonMgrBean (class: org.jnp.interfaces.NamingContext)
| | +- local (proxy: $Proxy217 implements interface org.jboss.ejb3.proxy.JBossProxy,interface com.pearson.ejb3.session.IButtonMgr)
| +- DBUtilBean (class: org.jnp.interfaces.NamingContext)
| | +- local (proxy: $Proxy186 implements interface org.jboss.ejb3.proxy.JBossProxy,interface com.pearson.ejb3.session.DBUtil)
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4165747#4165747
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4165747
17 years, 10 months
[JBossWS] - webmethod and object list return
by atriano
hi, I want to make a webmethod that returns an object list
for example:
| //class Person has a "name" attribute...
|
| @WebMethod
| public ArrayList getPool() {
| ArrayList array=new ArrayList();
| for(int i=0;i<5;i++){
| Person person=new Person("name"+i);
| array.add(person);
| }
| return array;
| }
when I run any webservice like this the console server throws an exception as follows:
ERROR [RequestHandlerImpl] Error processing web service request
| org.jboss.ws.WSException: javax.xml.ws.WebServiceException: javax.xml.bind.MarshalException
| - with linked exception:
| [javax.xml.bind.JAXBException: class org.jboss.soa.esb.samples.quickstart.model.
| Person nor any of its super class is known to this context.]
| at org.jboss.ws.WSException.rethrow(WSException.java:68)
| at org.jboss.wsf.stack.jbws.RequestHandlerImpl.handleRequest(RequestHandlerImpl.java:310)
| at org.jboss.wsf.stack.jbws.RequestHandlerImpl.doPost(RequestHandlerImpl.java:189)
| at org.jboss.wsf.stack.jbws.RequestHandlerImpl.handleHttpRequest(RequestHandlerImpl.java:122)
| at org.jboss.wsf.stack.jbws.EndpointServlet.service(EndpointServlet.java:84)
| ...
| ...
| ...
Can anybody help me?
thanks in advance,
Atriano
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4165745#4165745
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4165745
17 years, 10 months
[EJB 3.0] - Accessing stateless EJB3 bean from a WAR
by michael.litherland
Hi,
I've searched and read and tried a hundred things, but I'm pulling my hair out on this one. I have a desire to deploy similar, but subtly different EJB projects on a JBoss 4.2.2 application server, then allow my WARs to call those EJB methods using the remote interface. This way for a new customer I deploy a new EJB and the tweaks to the WAR are relatively minor to allow access to the additional EJB project. This seems like it should be straightforward, but I can't overcome a few problems. Here's part of my stateless bean:
| @Stateless
| @RemoteBindings({@RemoteBinding(jndiBinding="custom/remote/MyBean")})
| public class MyBean implements MyBean {
| @PersistenceContext(unitName = "S1-ejbPU")
| private EntityManager em;
| public List<SomeOtherBean> getBeans() {
| ...
|
My understanding is I need to create an ejb-ref in my web.xml, jboss-web.xml and finally call that from my code (which is a JSF managed bean in this case. First the jboss-web.xml:
| <jboss-web>
| ...
| <ejb-ref>
| <ejb-ref-name>ejb/MyBean</ejb-ref-name>
| <jndi-name>custom/remote/MyBean</jndi-name>
| <!-- also tried this:
| <jndi-name>jnp://localhost:1099/custom/remote/MyBean</jndi-name>
| -->
| </ejb-ref>
| </jboss-web>
|
The web.xml:
| <web-app ....
|
| <ejb-ref>
| <ejb-ref-name>ejb/MyBean</ejb-ref-name>
| <ejb-ref-type>Session</ejb-ref-type>
| <home/>
| <remote>MyBean</remote>
| </ejb-ref>
| </web-app>
|
Lastly in the code itself:
| @EJB(name="java:comp/env/ejb/MyBean")
| private MyBeanRemote mbr;
|
I've tried many variations, but it's not clear to me, even after reading documentation, what all of the various pieces actually do within this processes, nor what I should be calling what. I'd love to see a simplified howto for setting up something like what I desire or suggestions for "better ways" to attempt this.
Thanks,
Mike
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4165737#4165737
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4165737
17 years, 10 months
[Installation, Configuration & DEPLOYMENT] - Annoyance with EARs and .properties file
by sil
So I have a little annoyance here. Within my EAR I have a .properties file that multiple modules read from through an XML file by setting values to classpath:some.properties. It all works fine and dandy if I place the .properties file in the base of the EAR like so:
myApp.ear
| |
| |--- some.properties
| |
| |--- META-INF
| | |
| | |--- (some files)
| |
| |--- APP-INF
| | |
| | |--- lib
| | | |
| | | |--- (various .jar files)
|
However, I really want it to be read from APP-INF/classes instead, like so:
myApp.ear
| |
| |--- META-INF
| | |
| | |--- (some files)
| |
| |--- APP-INF
| | |
| | |--- lib
| | | |
| | | |--- (various .jar files)
| | |
| | |--- classes
| | | |
| | | |--- some.properties
I have tried adding a class path entry to the MANIFEST.MF file with no success. I have tried playing around in application.xml and jboss-app.xml as well. I always get the error:
java.io.FileNotFoundException: class path resource [some.properties] cannot be opened because it does not exist
I am looking for any tips or advice. Thanks!
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4165736#4165736
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4165736
17 years, 10 months
[JBoss Messaging] - Spring JmsTemplate questions
by TheOverlord
First I'll describe my configuration.
I'm sending a message from a JBoss AS to a remote queue on another JBoss AS using Spring's infamous JmsTemplate to send the message.
I read the advice concerning the use of Spring's JmsTemplate but I inherited this code so i'm hesitant to remove all references to JmsTemplate.
I read that I can use Spring's SingleConnectionFactory to reuse the JMS connection.
I have some question about this though.
It's my understanding that a single QueueConnectionFactory can be shared among different threads - is that correct?
It's also my understanding that a single connection created from a QueueConnectionFactory can be shared by multiple threads - is that correct?
If that is all correct, then why do I keep on reading about JMS connection pooling if the connection can be shared ? If they can be shared, you don't need a pool, you just need one connection - right?
I think I'm not understanding something correctly.
Please enlighten me.
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4165735#4165735
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4165735
17 years, 10 months