Rusty Enisin

Ranch Hand
+ Follow
since May 26, 2005
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 Rusty Enisin

I don't want to hurt anybody's brain or bring back painful memories, but I have a question on the difference between old EJB versions.

I have been asked to migrate a legacy application using EJB 1.1 to EJB 2.1. I am familiar with EJB 2.1 CMPs. However, I have not used the older EJB 1.1. Additionally the legacy application uses BMPs (another thing in which I have no experience). My client would like to still use BMPs in the "new" version.

I have looked through all kinds of documentation and specifications. It looks like as far as BMPs are concerned there is no difference. In EJB 2.0 and 2.1 they just added more CMP support.

As best I can tell the old 1.1 BMP EJBs should work as is in 2.1. This conclusion worries me. I fear I am missing something.

Does anybody out there have some experience or deeper knowledge in this subject? I could really use some help.
I am still not confident that the DefaultDS is using c3p0 for the connection pool. Any ideas on how to test it? I am still getting this error after about 8 hours of inactivity:

java.net.SocketException
MESSAGE: Broken pipe

STACKTRACE:

java.net.SocketException: Broken pipe
at java.net.SocketOutputStream.socketWrite0(Native Method)
at java.net.SocketOutputStream.socketWrite(SocketOutputStream.java:92)
at java.net.SocketOutputStream.write(SocketOutputStream.java:136)
at java.io.BufferedOutputStream.flushBuffer(BufferedOutputStream.java:65)
at java.io.BufferedOutputStream.flush(BufferedOutputStream.java:123)
at com.mysql.jdbc.MysqlIO.send(MysqlIO.java:2637)

It is entirely possible that c3p0 is working but is just not the proper solution for the problem. If so maybe I should create a new forum thread.
15 years ago
Hey. Thanks for the reply. You confirmed what I feared; I have three independent datasources, none of which are accomplishing what I need.

I made the changes you suggested as best I understood. I now have three files related to the database connections:

1. hsqldb-ds.xml
2. c3p0-service.xml
3. jms/mysql-jdbc2-service.xml

Here is how each is configured.

hsqldb-ds.xml


c3po-service.xml


jms/mysql-jdbc2-service.xml


The server started without errors and the connection works in the application. The database was disconnecting after a period of no use. Now I will wait a while to see if it disconnects.
15 years ago
Server configuration is not my specialty. I have an app I created that uses ejp3 over mysql. It was working fine except the database would disconnect after a period of inactivity. I decided to put in a connection pool that would manage this. C3P0 looked good and would be able to solve this problem.

Per the instruction on this site (http://www.mchange.com/projects/c3p0/#jboss-specific) I put the C3P0 jar in the jboss/server/default/lib dir. I created c3p0-service.xml per the site's instructions and then put it in the jboss/server/default/deploy dir. Restarting at this point causes no ill effect. I have C3P0 configured with AutomaticTestTable to ping periodically to keep the connection alive. I can see in my database that the table has been created. That tells me jboss found C3P0 and started it up.

Now this is where I get lost. Am I done? It seems to me that I now need to tell my old datasource (MySqlDS) to use C3P0 as the connection pool. Or do I now use the connection pool directly in the application instead of the old datasource (like in persistence.xml)?
15 years ago
Yeah. I am using OpenJPA. I was not able to find any way to set it. Also, the way this is set up persistance.xml is not used.

I ran out of time looking for a solution, so I just slapped synchronize on to the methods and called it good for now. This is not a high traffic app, so that will hold for now.
My app is using Struts2 + Spring + JPA (Standard). Currently the struts actions access service classes which return entities. All my service classes have Spring's @Transactional annotation on them. When more than one person uses the app lots of dead lock conflicts occur. This is really not cool.

I have tried changing the isolation levels for the transaction but I get an error saying that Standard JPA does not allow custom settings of isolation levels.

I have tried removing the annotation, which I really don't need but the quickstart app I based this one off of had it so I continued with it. Removing the annotation generated errors.

I tried removing the Spring bean for the transation manager. Surprise!... errors.

I don't really need transactions on these service classes. But I have not been able to find an alternative annotation. How is this supposed to be done in Standard JPA?
In my app I had I found if a user double-clicked on a search submit it generated a nasty error from my database (MySQL) about a dead lock problem.

Here is the first part of the error:



Having fixed the double-click problem, this has got me worried about collisions from multiple users trying to run a search simultaneously. If they happen to search at the same time won't one of them get the same error?

Is there a way to configure the transaction so that it will allow multiple reads at the same time?

Or is there a better replacement for the @Transactional annotation? This class does not really need a transaction. But when I take it off Spring does not know how to handle the entity.
Yes. I had persistance.xml in WebRoot/META-INF. This was incorrect. One of the things I noticed when I ran the maven build is that it was placed in src/META-INF. And applicationContext.xml was placed in src/ but I had placed it in /WEB-INF. It looks I had them in the wrong place.

I have since dropped Hibernate in favor of OpenJPA. And I have found bugs in Sruts2 that were resolved by moving to the latest version of Struts2. Where I had problems with this before, having persistence.xml in the right place seems to solve everything. Go figure...

Thanks for the response.
16 years ago
I guess it would seem appropriate to mention I am using Struts 2 version 2.0.6. After sleeping on this I realized this has to be a struts bug. I tried using JSTL tags to iterate over the collections, but that failed too. That means somehow the beans make it to the action but then the action is never available to the JSP

So I upgraded Struts2 to 2.0.9. Bingo. I can refresh the pages all I wish and they are always populated.
16 years ago
I found that it is really important to have exact version of jars specified. The easiest way to do this is run the maven script that comes in the download for the tutorial. Run the "mvn install" command first. Be sure you have the jta jar. Delete the test dir from the source code unless you have junit (they do not have it in the pom.xml).

Then run "mvn package" and maven will get all the dependent jars and then puts the app source and war file in a directory called "target". The jars are in target/quickstartSNAPSHOT/WEB-INF/lib.
16 years ago
This is one of the craziest things I have seen. I am building a Struts2/Spring/JPA/MySQL app. I am using the struts2 tags to iterate over and print out values of beans in collections. The beans are JPA Entity beans. The entities have ralationships mapped.

Everything appears to work fine. I load the page and it is populated correctly. I refresh the page and everything goes away. I put in some logging to see what was pulled from the database. Everything was there in the logs. The entities made it to the action class. But the tags in the JSP are rendering nothing. If I restart the app it works one more time again.

I have another page that I can refresh several times without a problem.

Any ideas?
16 years ago
Hey. Thanks. That really helps. I also found that I just needed to run "mvn package" and it would put everything in a directory called "target". And it compiled the .war file. Very smooth tool once you figure out how to use it.
16 years ago
I know nothing about Maven. But I am working through a tutorial that includes a pom.xml. Inside are listed all the dependant jars. When I run maven I cannot see where it downloads all the jars to. How can I specify a directory to which maven will put all the jars it downloads?
16 years ago
I am trying to run the Struts 2 + Spring 2 + JPA + AJAX tutorial found at http://struts.apache.org/2.x/docs/struts-2-spring-2-jpa-ajax.html. But exceptions keep getting thrown during startup of tomcat. Try as I might I cannot seem to resolve it. Here is the error:



The key part appears to be



All the code is copied directly from the tutorial page. Any ideas?
16 years ago
Thank you. That makes sense. I will do it that way.
16 years ago