Mark Manns

Greenhorn
+ Follow
since Jul 06, 2006
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 Mark Manns

Hi All

I'm trying to use openjpa 1.1 in weblogic ( it comes with weblogic 10) but I keep getting the error:

Caused by: <openjpa-1.1.0-r422266:657916 fatal user error> org.apache.openjpa.persistence.ArgumentException: A JDBC Driver or DataSource class name must be specified in the ConnectionDriverName property.
at org.apache.openjpa.jdbc.schema.DataSourceFactory.newDataSource(DataSourceFactory.java:72)
at org.apache.openjpa.jdbc.conf.JDBCConfigurationImpl.createConnectionFactory(JDBCConfigurationImpl.java:776)
at org.apache.openjpa.jdbc.conf.JDBCConfigurationImpl.getDBDictionaryInstance(JDBCConfigurationImpl.java:553)
at org.apache.openjpa.jdbc.meta.MappingRepository.endConfiguration(MappingRepository.java:1250)
at org.apache.openjpa.lib.conf.Configurations.configureInstance(Configurations.java:505)
at org.apache.openjpa.lib.conf.Configurations.configureInstance(Configurations.java:430)
at org.apache.openjpa.lib.conf.PluginValue.instantiate(PluginValue.java:103)
at org.apache.openjpa.conf.MetaDataRepositoryValue.instantiate(MetaDataRepositoryValue.java:68)
at org.apache.openjpa.lib.conf.ObjectValue.instantiate(ObjectValue.java:83)
at org.apache.openjpa.conf.OpenJPAConfigurationImpl.newMetaDataRepositoryInstance(OpenJPAConfigurationImpl.java:843)
at org.apache.openjpa.conf.OpenJPAConfigurationImpl.getMetaDataRepositoryInstance(OpenJPAConfigurationImpl.java:834)
at org.apache.openjpa.kernel.AbstractBrokerFactory.makeReadOnly(AbstractBrokerFactory.java:638)
at org.apache.openjpa.kernel.AbstractBrokerFactory.newBroker(AbstractBrokerFactory.java:183)
at org.apache.openjpa.kernel.DelegatingBrokerFactory.newBroker(DelegatingBrokerFactory.java:142)
at org.apache.openjpa.persistence.EntityManagerFactoryImpl.createEntityManager(EntityManagerFactoryImpl.java:192)
at org.apache.openjpa.persistence.EntityManagerFactoryImpl.createEntityManager(EntityManagerFactoryImpl.java:145)
at org.apache.openjpa.persistence.EntityManagerFactoryImpl.createEntityManager(EntityManagerFactoryImpl.java:56)
at com.ets.domain.messagecustom.MessageCustomDao.<init>(MessageCustomDao.java:22)

line 22 in MessageCustomDao is:

// MessageCustomJPAPersistenceUnit is defined in the persistence.xml
emf = Persistence.createEntityManagerFactory("MessageCustomJPAPersistenceUnit");
em = emf.createEntityManager(); // LINE 22

my persistence.xml looks like:

<?xml version="1.0"?>
<persistence>
<persistence-unit name="MessageCustomJPAPersistenceUnit"
transaction-type="JTA">
<provider>org.apache.openjpa.persistence.PersistenceProviderImpl
</provider>
<class>com.Class1</class>
<class>com.Class2</class>
<class>com.Class3</class>
<jta-data-source>jdbc/JPADataSource</jta-data-source>
<properties>
<property name="openjpa.ConnectionDriverName" value="oracle.jdbc.OracleDriver" />
</properties>
</persistence-unit>
</persistence>

and the JPADataSource is a tested DataSource targeted to my weblogic server instance and tests green.

can anyone tell me what the problem is - this is my first attempt at using a JPA implemenation? is my persistence.xml incorrect? am i not creating the entity manager factory or entity manager correctly?

Any help would be appreciated.

Mark
All

I needed to block double page submits on the server (I know, I know, lots of people say do it on the browser side, but I didn't - well, actually, I did, but didn't like the results). I used a token on the page and a servlet filter that had a token cache - I also used a timer task to clean out the cache every so often. I didn't store the token on the session because the code invalidates the session for performance reasons. It seems to work quite well so far so I thought I would share it.

Hope the code below is helpful - and if you see any issues, please post... ;)
mm


11 years ago
Hi Mark

Thank you for the response - sorry it's taken so long to circle back on this. We were still on spring version 1.2.8. I've upgraded to spring 3.0.1 and hibernate 3.3.2.

Can you point me to docs that might help me understand how to replace the HibernateDaoSupport and HibernateTemplate ?

Thanks again,
MM
Hi All,

I need some help. We have a struts app that uses Spring and Hibernate3. When Hibernate does a load() (sql Select) we unencrypt some of the data in the record. As a result, Hibernate suspects the record might be dirty and checks by doing a SQL Update. We don't want this overhead - and also - it's causing hibernate stale object exceptions as we use an optimistic approach - so if one user saves a record while another user is trying to load it the load fails (we handle dirty conditions on the save).

To turn off the update statement calls I set the flush to NEVER on both the session and the hibernate template objects - this works great.

Here's the question:

Since we use Spring we used to call getHibernateTemplate on the Spring HibernateDaoSupport object, but the docs indicate

NOTE: from the doc on getHibernateTemplate() method -
The returned HibernateTemplate is a shared instance.
You may introspect its configuration, but not modify the
configuration (other than from within an DaoSupport.initDao()
implementation). Consider creating a custom HibernateTemplate
instance via new HibernateTemplate(getSessionFactory()), in which
case you're allowed to customize the settings on the resulting instance.

so now we call

HibernateTemplate lHibernateTemplate = new HibernateTemplate(getSessionFactory());

but this means that for every query we're creating a new HibernateTemplate object that will hang around until the garbage collector runs as opposed to using the shared one --- this application gets hammered on in production so we're concerned about that.

Does anyone have any thoughts about the performance issues of calling new on the HibernateTemplate over and over and over like that? We're not expert Hibernate users so maybe it's a non-issue, but we want to be careful.

Or - any one know of another way to turn off the flushing that causes the sql update right after the sql select ?

Thanks for any feedback,
MM
the input parameter tells struts where to go if the form validation fails - it's not the 'input' jsp to the action (i don't like the choice of 'input' here). you display a jsp that has an html form and some type of submit action. when the submit is sent from the browser the struts ActionServet looks for a match in the action mapping and calls that action sending the request data - the name="myForm" parameter is the ActionForm class you created and that's where struts will place the data from the html request - saving you the trouble of getting parameters off the request.
15 years ago
did you enable validation? you have to add this to the struts-config.xml file so struts can find the validation xml files:

<plug-in className="org.apache.struts.validator.ValidatorPlugIn">
<set-property property="pathnames"
value="/WEB-INF/validator-rules.xml,
/WEB-INF/validation.xml"/>
</plug-in>
15 years ago
Hi Peter

I downloaded appfuse --- a spring kickstart. I used the spring MVC rather than struts. I think if you're going to use Spring you might want to think about dropping struts all together. Spring will allow you to uncouple your business classes from the service classes via dependency injection - which is nice. It will also give you aspects so you can configure stuff like logging without having to pollute your business classes with code to do logging. Spring MVC goes a step farther than struts in that it will populate your backend model classes via the Command object - which saves you from having to create a model object in your controller class and then populate it with values from the struts ActionForm.

Just my $.02.
15 years ago
your ActionForm should have a property called "mySelect" - and struts will place the value in there. or you can get "mySelect" off the request if you don't have an ActionForm.
15 years ago
Hi Everyone

I want to control the code that shows up in the html:form tag action property in the jsp (i.e. action="/internal/save.do" or action="/internal/update.do"). I'm using the same jsp and ActionForm - the only thing different is the controller selection. I can render the page if I put something like "nextAction" "/internal/save.do" onto the request and then use a scriptlet in the jsp --- but I don't like this approach.

Does anyone know how to address this problem?
Any help greatly appreciated.

Mark
15 years ago
Thanks much for the reply

Mark
15 years ago
Hi All

I'm getting the following exception in my web server log file:

Original Exception:
java.net.SocketException: Software caused connection abort: socket write error
........and then a big old stack trace that seems to indicate looping

my question is this:

If my web server (weblogic 8.1) invokes a jsp that loops and loops and loops and never sends back a response ---- will the web server time out the connection and throw a socket exception?

Thanks,
mm
15 years ago
What are the best tools on the market today to facilitate round tripping? I want to build my design using a modelling tool, crank out the code (java in my case), be able to edit the code and parse it back into the tool as needed.

mm
A forward does the same thing --- invokes the servlet filter.
15 years ago
Hi All

I have a servlet filter with a try/catch. In the exception catch I use a sendRedirect to my error.jsp. But that doesn't work --- the sendRedirect invokes the filter again --- and that fails again --- and that sends another redirect .... and on and on and on.

I know I can use response.sendError(..) but that doesn't give me my pretty error page.

Any ideas anyone?

Thanks

Mark
15 years ago