Deependra Tewari

Greenhorn
+ Follow
since Apr 12, 2006
Merit badge: grant badges
For More
Cows and Likes
Cows
Total received
0
In last 30 days
0
Total given
0
Likes
Total received
0
Received in last 30 days
0
Total given
0
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by Deependra Tewari

So here's what I'm trying to do and stuck at:

I have a shared Eclipse Java project with @Entity (EJB 3.1) classes that is used by a couple of other Eclipse WebApp projects. This project itself has no persistence.xml! The other WebApp projects that use this project declare their own persistence.xml under WebContent/META-INF and refer to the JAR of this project in their persistence.xml using the jar-file tag. Of course the shared project's JAR is added as a deployment dependency in these WebApp projects and is placed under WEB-INF/lib.

Now I am creating JUnit4 Testcases to test Stateless session beans in these WebApp projects. I'm using Apache TomEE 1.5.0 Plus and in the testcase I use a @Before method to start the OpenEJB container in Embedded mode using EJBContainer.createEJBContainer() method. For this to work properly, I have created an alternate test.persistence.xml (that uses a different datasource to an HSQL memory db and creates the tables using forward mapping). I have placed this in META-INF of the src folder and in the @Before method, I set the "openejb.altdd.prefix" to "test" so that the alternate test.persistence.xml is read. All this setup is working.

The trouble is that as soon as OpenJPA 2.2.0 starts, it complains that there are no persistent classes from the shared project! This is because, the jar-file tag in test.persistence.xml refers to a jar that doesn't exist! When Eclipse deploys the other WebApp projects, it creates the JAR under WEB-INF/lib and the actual persistence.xml refers to the jar under that path! However, I do not find any such JAR when running a JUnit testcase.

So how do I refer to this JAR or the classes in the shared project in the test.persistence.xml without making the testcase itself overly dependent on deployment structure or any specific hard-coded path! This testcase will eventually be committed to the repository and hence must be such that any dev checking it out can simply run it.

Any pointers in the right direction would be greatly appreciated!
Hi,
I need to develop a system for a requirement where there needs to be a module or plug-in like system with a web front end. Each module/plug-in will be doing a specific job and may have associated views in the form of JSP pages for IO. The web front must be available at all times and the modules need to be loaded/unloaded at run time dynamically via user intervention.

I figured OSGi would give me the constant uptime and the dynamic loading/unloading of the modules. I am currently trying a proof of concept using Springsource DM Server and Springsource Tool Suite.

I have fairly limited knowledge of Spring itself and as such prefer to use programmatic approach rather that declarative approach.
So the architecture I have thought of is something as follows:

OSGi'fied Webapp running in DM Server, the webapp has a reference to a OSGi service that is given by another bundle. Now this bundle tries to get a list of all the bundles using bundleContext.getBundles() and then tries to look for the registeredService of each bundle. The idea is that if I can make a list of all the bundles and their exported services, then I can give this list to the webapp and it can then show what plug-ins are loaded and also forward requests to such plug-ins.

The problems:

[1] Each plug-in can have a different interface and if I don't have the interface handle in the webapp source code, I can't call their methods!

[2] Also, is their a way to get access to all services exported by various bundles without declaring them in applicationContext.xml of the webapp? This way new bundles can be probed timely or maybe using the ServiceListener interface!

[3] I might provide a common interface with a set of methods that plug-ins must implement. However, if many bundles export their service for a common interface, I understand that the last one to be loaded is what all others will get. Is their a way of getting all the services without using ranks? I may distinguish them then using some property they must expose via one of the interface methods.

I wan't to use the least of Spring or declarative model. This way I can just provide a bundle or jar and let others create new plug-ins.

I understand that I may be looking at the architecture from a wrong perspective. Insights on this would also be highly appreciated!

I'm still going through the OSGi specs so will be ignorant of a lot of things. Please do point me in the right direction if so.

Thanks
Hi,

I'm writing a servlet which is to act as a facade for the web application.
It needs to check some details and the forward to the requested uri.

I have declared the web.xml entry as

<servlet><description>This is the main Facade for the webapp</description>
<display-name>Facade</display-name>
<servlet-name>Facade</servlet-name>
<servlet-class>com.myapp.web.servlets.Facade</servlet-class>
<load-on-startup>2</load-on-startup>
</servlet>

<servlet-mapping>
<servlet-name>Facade</servlet-name>
<url-pattern>/*</url-pattern>
</servlet-mapping>

Within the servlet, I'm trying to forward like this

ServletContext ctx = getServletConfig().getServletContext();
ctx.getRequestDispatcher("/jsp/signin.jsp").forward(request, response);

Now the problem is that as soon as i forward, the request comes back to the facade again. This results in a recursive looping.

Any insights how I can break that.
I'm using Tomcat 6 & I can't have urls like *.do. No extensions.
So its like I need every incoming request to come to my facade but not the ones that the facade itself forwards.
I'm kind of stuck here [banghead]
Thanks
16 years ago
Hi,

I'm writing a servlet which is to act as a facade for the web application.
It needs to check some details and the forward to the requested uri.

I have declared the web.xml entry as

<servlet><description>This is the main Facade for the webapp</description>
<display-name>Facade</display-name>
<servlet-name>Facade</servlet-name>
<servlet-class>com.myapp.web.servlets.Facade</servlet-class>
<load-on-startup>2</load-on-startup>
</servlet>

<servlet-mapping>
<servlet-name>Facade</servlet-name>
<url-pattern>/*</url-pattern>
</servlet-mapping>

Within the servlet, I'm trying to forward like this

ServletContext ctx = getServletConfig().getServletContext();
ctx.getRequestDispatcher("/jsp/signin.jsp").forward(request, response);

Now the problem is that as soon as i forward, the request comes back to the facade again. This results in a recursive looping.

Any insights how I can break that.
I'm using Tomcat 6 & I can't have urls like *.do. No extensions.
So its like I need every incoming request to come to my facade but not the ones that the facade itself forwards.
I'm kind of stuck here
Thanks
16 years ago
thanks its working now.

sorry for not being alert .....
17 years ago
Hi,

IMHO I think that you can keep attributes required on the current form from the previous form in the request object and attributes required throughout on all pages in the session object.
17 years ago
Here's the action class
-----------------------------------------------------------------------------

-----------------------------------------------------------------------------
Here's the jsp that displays the ArrayList
-----------------------------------------------------------------------------

-----------------------------------------------------------------------------
struts-config.xml entry relevant to this page
-----------------------------------------------------------------------------

-----------------------------------------------------------------------------
Thanks

Added [ c o d e ] [ / c o d e ] tags to make this readable - Merrill
[ July 31, 2006: Message edited by: Merrill Higginson ]
17 years ago
Hi there,
I'm trying to get an ArrayList back on a jsp page that i had previously added to the request object using request.setAttribute("name",listObject);

I had added it in the execute method of Action class that will forward to this jsp page where i want to get back this ArrayList and show its details !!!

However the page comes out to be blank. not even the table headings are visible !!! the struts-config.xml,web.xml, and context.xml are all ok !!!

Thanks
17 years ago
Hi, I'm new to java and currently going through the various design patterns after conquering J2EE basics. I'm currently refering to J2EE Design Pattern by Crawford & Kaplan - O'Reilly.

According to them, when using Business Delegate Pattern, the business delegate should reside on the business tier only.

Now does that imply that it should be in the same package as the EJB and other POJOs?

Also some web sites and at-least two implementations I've seen say that the business delegate must reside on the web tier ie in the package at the web tier? I feel this is more logical also !

So which one is better or correct?

Finally if the business delegate resides on the business tier, then it doesn't need to lookup the EJB I guess (being in the same package)?

So how will the client code lookup this business delegate? Then it probably also won't require the ServiceLocator Class also?

Please help as I'm terribly confused.
18 years ago
My guide introduced me to J2EE and now I like it and hate it at the same time !

There are sooooo many things in it that by the time you get the feel of any one thing, the world alrady has something new.

As I finished understanding JDBC (barely able to set-up an use a DataSource of JDBC 3.0) I got a shocker of Hibernate !! :roll:

As I realized there is something called Struts implementing the controller servlet design pattern, I get a new name SPRING framework !! :roll:

Gr8. But right now I think I'll stick to refurbishing my servlets/jsp/ejb basics and start with design patterns alongwith.
18 years ago
I started my learning using NetBeans 5.0 as I was advised by my guide.After using it for sometime, I tried Eclipse on my friend's workstation. However it's layout was very confusing, cluttered and it required some plug-in for Java which was missing so It was like ouch experience.

Right now I'm trying to get my hands on Eclipse Distilled and see what happens.

By the way what about the Sun Java Studio EE 8? It's layout seems OK to me and I could deploy an EJB as easily as on NetBeans. But there aren't many books around on any of these (SJS EE8 & NetBeans 5) nor do I find many reviews on them. Right now I'm using NetBeans and will give Eclipse a try.
Meanwhile I'd really like some advice on good books for NetBeans 5. Thanks
Which IDE to use espeially while learning J2EE.

Currently I'm using Netbeans 5. But a lot of my friends say IBM's WebStudio is better (although I've found IBM's products intimidating). I tried Eclipse but I figured using notepad with command line was easier as I couldn't make anything out of it. So right now I'm sticking with NetBeans but what about IntelliJ IDEA, Sun Java Studio EE 8 etc.
Hi,
I am new to Java especially to EE. I come from a C, C++ background building standalone apps. In the client-server or enterprise level I've virtually no experience.In J2EE, there are so many things & all of them seem to be important for developing an enterprise app that I'm absolutely confused as to what to begin learning first.

I'm familiar with J2SE. I can also write servlets, Basic JSP (without tags) and basic EJB that can connect to a db using JDBC.

But I've understood that what I know is very basic. I need to do more coding and that requires spending time. It's an investment I'm going to do but in an organized manner.

So should I first go through all the design patterns or should I first go through EJB then servlets and JSP and in the end look at design patterns. What I feel is that design patterns govern the overall app development and hence the required skill-set!

Please advice me so that I may not end up as a gr8 hoch-poch.
18 years ago