I have a Java EE Enterprise application which comprise of EJB module and JSF based Web module.
I have created EJB Stateless Bean, and now I need to call method of that bean from Web module Managed Bean, but compiler gives me an error.
I'm just starting with Java EE so I really don't have best of idea what should I look into
So based on comments above I have solved this problem.
I went to web module of my application and to lib folder of it.
Right click -> add project
Found my EJB module and selected it. Not sure if this is good idea, but for now it seems it works.
Related
I'm trying to create a portlet with liferay 6.2 and using spring. If I create a bean without using constructor-arg or factory-method then everything works fine. But if I use either of these then I get exceptions when the portlet is deployed.
an example:
the exception I'm getting is:
01:28:21,884 ERROR [ContextLoader:323] Context initialization failed
java.lang.IncompatibleClassChangeError: class org.springframework.core.LocalVariableTableParameterNameDiscoverer$ParameterNameDiscoveringVisitor has interface org.springframework.asm.ClassVisitor as super class
I realize that this can be caused by having 2 versions of ams, but im using the spring jars that come with liferay.
You give an option yourself - duplicate classes. But without knowing how you build and what you're doing, there's hardly anything to do apart from asking you to make extra extra extra sure that you don't have duplicate resources on the classpath:
Check your deployed web application (once it's deployed to your application server) and its WEB-INF/lib folder for such duplicates. They might come in only during the buildprocess, e.g. they might not be in your IDE's workspace. Or Liferay might inject them (due to declared dependencies) during deployment.
You'll have to figure out how (and in which phase) those resources get there, then eliminate that option (e.g. through proper maven scope, e.g. "provided")
I am trying to narrow down the major changes in in EJB 3 and EJB 2, and noted the following changes
EJB 3.X does not required a deployment descriptor; does this mean we can not have a deployment descriptor ?
Also the home and the remote interfaces ? does this mean we can not implement any the aforementioned interfaces in EJB 3.x. Can someone explain what are the main use of Home and the remote interfaces in EJB 2.x
EJB 2.x does not use or implement POJOs , can some one explain the exact use of POJOs in EJB 3.x, with a minor example
I have covered EJB 3, yet I do not have any knowledge in EJB 2.x
Regards
Rashendra
ad 1/ One can certainly have explicit XML-based deployment descriptor with EJB 3.0. However, as compared with 2.x, it is not anymore obligatory to have one. One uses explicit XML deployment descriptor when some of the settings specified on Java class itselfs needs to be augmented.
ad 2/ There is an remote/local bean interface with EJB 3.0, obligatory with remote beans and optional with local beans. There is no home interface in 3.x anymore, which was used to manage the live cycle of entity beans (read:data) and session beans in 2.x. As the entity beans have been replaced by JPA and the life cycle management of session beans has been removed from the client code written by application developer, there is no need for home interface anymore.
ad 3/ Have a look at Java EE tutorial, it covers this well and there are certainly examples.
I have a portal server. There are number of portlets installed. I have environment configs file which is same for all portlets installed on that app server. I am using apache commons-configuration for managing from the configuration files.
Right now, each portlet/component build their own EnvConfiguration bean from these files. Obviously this is eating up more memory. I want to separate out the creation of EnvConfiguration bean and share it across all the portlets. Basically, I want to create only one bean per app server.
What are the best possible ways to do this? And how will this common beans(s) injected into the needed components?
Edit: This is a liferay application and non EAR model
Thanks
Sundar
You can use the parentContextKey web.xml param.
Here is a blog post explaining how : http://spring.io/blog/2007/06/11/using-a-shared-parent-application-context-in-a-multi-war-spring-application/
The idea is to package and declare the beans you want to share in a common jar (if you use Tomcat, you can put it in the server lib folder). The beans are declared in a file called beanRefContext.xml (default name, can be changed), with an id. Then you add the param "parentContextKey" in the web.xml of your webapps with the id previously mentionned.
I'm trying to inject a EJB within my RESTful Service (RESTEasy) via Annotations.
public class MyServelet implements MyServeletInterface {
...
#EJB
MyBean mybean;
...
}
Unfortunately there is no compilation or AS error, the variable "mybean" is just null and I get a NullPointerException when I try to use it.
What I'm doing wrong?
Here are some side-informations about my architecture:
JBoss 4.2.2.GA
Java version: 1.5.0_17
local MDB-Project
remote EJB-Project
WAR Project with the RESTful Service which uses the remote EJB and sends messages to the local MDB-Project
Thanks in advance!
br
Dominik
p.s: everything is working fine when I use normal context lookup.
I had a similar problem (though without #Remote beans). The way it worked for me - sample application is here: https://github.com/kubamarchwicki/rest-app/ (this works: https://github.com/kubamarchwicki/rest-app/blob/master/service-webapp/src/main/webapp/WEB-INF/web.xml#L9)
The crack with context lookup is that the name changes with a change of the ear name. If you fancy things like versions, it makes the whole thing hard to trace or forces you to hardcode ear name somewhere in the code.
Just a few cents to an old discussion ;-)
This is not exactly my forte, so maybe I am way off... but, can you do EJB stuff in a WAR? I was under the impression you needed to do EJB work in an EAR.
JBoss 4.2.2.GA is not a fully compliant Java EE 5 server, it does not support EJB references injection in servlets or application clients, only in the EJB layer. Use JBoss 5 for that (or perform a lookup).
JBoss 4.2.2.GA supports only Servlet 2.4. There is no support of DI on Servlet 2.4. Hence you always get 'null' for myBean variable. As suggested, please migrate to JBoss 5.0 which supports Servlet 2.5 which makes use of Java 5 features like annotations.
I'm trying to deploy an EJB in JBoss that uses the #WebService annotation. However, the EJB has a dependency on an EJB in another ear. By adding the #Depends annotation, the EJB start is delayed until after the ear is loaded, but it appears the WebService generator is still trying to start up the generated WAR as soon as it sees the annotation.
Is there anything similar to #Depends for the generated JBossWS that I can add?
I think what you may need to do is configure the deployment order that JBoss is using. I know this is possible and I think it is what people I work with have done for dependencies like this. If this link doesn't help, you will want to search for something dealing with JBoss deployment order and how to set the order. I had JBoss training a while back and I know this is a solution that is taught.
JBoss Deployment Order