dev@glassfish.java.net

Re: PU with TX Type JTA

From: Arun Gupta <Arun.Gupta_at_Sun.COM>
Date: Wed, 20 Jun 2007 05:51:40 -0700

I put some more time on this and got a better handle on my environment.

Until now, To create a PU I was creating a Java Library in NetBeans and
was seeing only jdbc:derby://localhost:1527/sample as DataSource. Then I
was importing this Library in my Web Project. However when I create PU
within a webapp, then it shows jdbc/sample. That's happening because
Webapp is to be deployed on GlassFish and has appropriate context to
read JNDI sources. With that, I'm able to make progress and finally
could create a "Hello JPA World". The detailed instructions for that are
now available at:

http://blogs.sun.com/arungupta/entry/hello_jpa_world

Thanks,
-Arun

Lance J. Andersen wrote:
> Hi Arun,
>
> Here is a simple Hello World web Application using
>
> JSPs/JSTL/simple Java Bean, JPA (Resource-Local Tx).
>
> You will need to tweak the persistence.xml and the run property for the
> project to point to your glassfish
>
> To run
> http://<host>:<port>/JPAWeb/
>
>
> I will probably clean this up a bit more and push it as a blog later
> this week.
>
>
> FWIW, i did find it a bit painful to tweak the persisitence.xml in NB
> 5.5as i could not do anything but use a datasource because i was
> configured to deploy to Glassfish. It should allow me to choose whether
> I am using jta/datasource or a local resource without editing it by hand
> (in the xml view).
>
> Also, you might have to stop and restart your domain if you
> deploy/undeploy as the build of v2 i had seemed to be a bit touchy to
> constant redeployments.
>
> Let me know if this is what you were looking for.
>
> -lance
>
> Arun Gupta wrote:
>>> http://weblogs.java.net/blog/ss141213/archive/2005/12/introduction_to.html
>>> as this is a simple servlet that Sahoo created.
>> persistence.xml in the blog is:
>>
>> <persistence xmlns="http://java.sun.com/xml/ns/persistence"
>> version="1.0">
>> <persistence-unit name ="em1"/>
>> </persistence>
>>
>> This is very different from the one generated by default now. Does it
>> seem right ?
>>
>>>>> http://weblogs.java.net/blog/lancea/archive/2007/06/using_java_web.html
>>>>>
>>>> This is a recent entry and has way too much details for HW.
>>> could u please explain what HW is? Is it Home Work?
>> Hello World :)
>>
>>>>
>>>> Bullet#5 says "default data source jdbc/sample". This is not valid
>>>> for GlassFish V2 b50/NB 5.5.1. My code is now:
>>> This is the old sample default DataSource config in Glassfish.
>>> jdbc/__default is what ships now.
>> Hmm, I don't see any in my NetBeans :(
>>
>>>> oracle.toplink.essentials.exceptions.DatabaseException
>>>> Internal Exception: java.sql.SQLException: Table/View 'COMPANY' does
>>>> not exist.
>>> I would enable logging via
>>> <property name="toplink.logging.level" value="FINE"/>
>> Where/How do I specify this entry ?
>>
>>>
>>> to see what is happening at deploy time as it looks like your table
>>> is not being created.
>> Yes, I can see that from the error message. But what's weird is that
>> I'm seeing this message during em.query and not during em.persist.
>>
>> -Arun
>>
>>>
>>>
>>>> Error Code: -1
>>>> Call: SELECT ID, CHANGE, PERCENTCHANGE, PRICE, LASTUPDATED,
>>>> COMPANYNAME FROM COMPANY WHERE (ID = CAST (? AS VARCHAR(32672) ))
>>>> bind => [1]
>>>> Query: ReportQuery(sample.Company)
>>>> at
>>
>>
>
> ------------------------------------------------------------------------
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: dev-unsubscribe_at_glassfish.dev.java.net
> For additional commands, e-mail: dev-help_at_glassfish.dev.java.net

-- 
Technology Evangelist
Web Technologies and Standards
Sun Microsystems, Inc.
Blog: http://blogs.sun.com/arungupta