[JBoss Seam] - Seam Unit Testing Problem: javax.naming.NamingException: Loc
by i77ac_10
Hi,
I'm following this example (http://docs.jboss.com/seam/1.2.1.GA/reference/en/html/testing.html#d0e15875) for writing a unit test for seam. However, I'm getting a NamingException when I try to create the EntityManagerFactory. Anyone know whats up with this?
Here is the code for creating the EntityManagerFactory
emf = Persistence.createEntityManagerFactory("myPersistenceUnitName");
Here is the exception stack trace:
javax.persistence.PersistenceException: org.hibernate.HibernateException: Could not find datasource
| at org.hibernate.ejb.Ejb3Configuration.createEntityManagerFactory(Ejb3Configuration.java:217)
| at org.hibernate.ejb.HibernatePersistence.createEntityManagerFactory(HibernatePersistence.java:114)
| at javax.persistence.Persistence.createEntityManagerFactory(Persistence.java:37)
| at javax.persistence.Persistence.createEntityManagerFactory(Persistence.java:27)
| at test.model.TestNGTest.init(TestNGTest.java:61)
| at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
| at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
| at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
| at java.lang.reflect.Method.invoke(Method.java:585)
| at org.testng.internal.MethodHelper.invokeMethod(MethodHelper.java:529)
| at org.testng.internal.Invoker.invokeConfigurationMethod(Invoker.java:311)
| at org.testng.internal.Invoker.invokeConfigurations(Invoker.java:149)
| at org.testng.internal.TestMethodWorker.run(TestMethodWorker.java:77)
| at org.testng.TestRunner.privateRun(TestRunner.java:614)
| at org.testng.TestRunner.run(TestRunner.java:505)
| at org.testng.SuiteRunner.privateRun(SuiteRunner.java:221)
| at org.testng.SuiteRunner.run(SuiteRunner.java:147)
| at org.testng.TestNG.createAndRunSuiteRunners(TestNG.java:576)
| at org.testng.TestNG.runSuitesLocally(TestNG.java:539)
| at org.testng.TestNG.run(TestNG.java:316)
| at org.testng.TestNG.privateMain(TestNG.java:666)
| at org.testng.TestNG.main(TestNG.java:608)
| Caused by: org.hibernate.HibernateException: Could not find datasource
| at org.hibernate.connection.DatasourceConnectionProvider.configure(DatasourceConnectionProvider.java:56)
| at org.hibernate.connection.ConnectionProviderFactory.newConnectionProvider(ConnectionProviderFactory.java:124)
| at org.hibernate.ejb.InjectionSettingsFactory.createConnectionProvider(InjectionSettingsFactory.java:29)
| at org.hibernate.cfg.SettingsFactory.buildSettings(SettingsFactory.java:61)
| at org.hibernate.cfg.Configuration.buildSettings(Configuration.java:1928)
| at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1211)
| at org.hibernate.ejb.Ejb3Configuration.buildEntityManagerFactory(Ejb3Configuration.java:631)
| at org.hibernate.ejb.Ejb3Configuration.createEntityManagerFactory(Ejb3Configuration.java:760)
| at org.hibernate.ejb.Ejb3Configuration.createFactory(Ejb3Configuration.java:151)
| at org.hibernate.ejb.Ejb3Configuration.createEntityManagerFactory(Ejb3Configuration.java:205)
| ... 21 more
| Caused by: javax.naming.NamingException: Local server is not initialized
| at org.jnp.interfaces.LocalOnlyContextFactory.getInitialContext(LocalOnlyContextFactory.java:45)
| at javax.naming.spi.NamingManager.getInitialContext(NamingManager.java:667)
| at javax.naming.InitialContext.getDefaultInitCtx(InitialContext.java:247)
| at javax.naming.InitialContext.init(InitialContext.java:223)
| at javax.naming.InitialContext.<init>(InitialContext.java:175)
| at org.hibernate.util.NamingHelper.getInitialContext(NamingHelper.java:28)
| at org.hibernate.connection.DatasourceConnectionProvider.configure(DatasourceConnectionProvider.java:52)
| ... 30 more
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4036220#4036220
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4036220
19 years
[EJB 3.0] - Re: Implementing an EJB3 Interceptor without touching the pr
by Haensel
Heya,
thank you so much for your reply.
The changes I made for my ejb3 Inteceptor looks like this:
<interceptor class="haensl.ejb3interceptors.MyDefaultInterceptor" scope="PER_CLASS"/>
|
| <domain name="Stateless Bean">
| <bind pointcut="execution(public * *->*(..))">
| <interceptor-ref name="org.jboss.ejb3.asynchronous.AsynchronousInterceptor"/>
| <interceptor-ref name="org.jboss.ejb3.ENCPropagationInterceptor"/>
| <interceptor-ref name="org.jboss.ejb3.security.AuthenticationInterceptorFactory"/>
| </bind>
| <bind pointcut="execution(public * @org.jboss.annotation.security.SecurityDomain->*(..))">
| <interceptor-ref name="Basic Authorization"/>
| </bind>
| <bind pointcut="execution(public * @javax.annotation.security.RunAs->*(..))">
| <interceptor-ref name="org.jboss.ejb3.security.RunAsSecurityInterceptorFactory"/>
| </bind>
| <bind pointcut="execution(public * @org.jboss.annotation.ejb.Clustered->*(..))">
| <interceptor-ref name="org.jboss.ejb3.remoting.ReplicantsManagerInterceptorFactory"/>
| </bind>
| <bind pointcut="execution(public * *->*(..))">
| <interceptor-ref name="org.jboss.ejb3.stateless.StatelessInstanceInterceptor"/>
| <interceptor-ref name="org.jboss.aspects.tx.TxPropagationInterceptor"/>
| <interceptor-ref name="org.jboss.ejb3.tx.TxInterceptorFactory"/>
| <interceptor-ref name="org.jboss.ejb3.AllowedOperationsInterceptor"/>
| <interceptor-ref name="org.jboss.ejb3.entity.TransactionScopedEntityManagerInterceptor"/>
| <interceptor-ref name="org.jboss.ejb3.interceptor.EJB3InterceptorsFactory"/>
| <!--interceptor-ref name="haensl.ejb3interceptors.MyDefaultInterceptor"/ -->
| </bind>
For loading this interceptor by all ejbs which are deployed on the server I just have to copy my .jar file with the interceptor to the lib folder of the server ?
It still doesnt work that way.
And with deployment descriptors I only worked so far that I know that I have to add them to the target projects which needed to be intercepted.
But by this I have to "touch" those projects. And that is not my intention.
Or is there some kind of "global deployment descriptor folder" in the server structure ?
Thank you so much,
Hans
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4036217#4036217
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4036217
19 years
[EJB/JBoss] - Accessing properties from jboss
by veeseekay
Hi,
Am using jboss AS, and,
I would like to give some configuration values(typically key-value). I have a scenario to access certain key values from a config file,
I can do it through Properties class and FileInputStream, but i don want to hardcode path to the config file,
I also can do it through ClassLoader.getResourceAsStream ("resource.properties");
But what I am wondering here is if I can configure props using something like jboss.properties,etc, so that props are loaded when jboss starts up, and I can access those props through System.getProperty()
I do not want to access the property from a servlet or from an MBean,
My scenario is to get some config values from a property file and use it in a few helper classes that I have written to carry out some general functions, for ex, I want to access a timeout value from the property file in the helper class!
how do I achieve this, or what is the right way of doing this
Appreciate your help!
Thanks
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4036213#4036213
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4036213
19 years
[JBoss Seam] - s:convertDateTime and s:selectDate without specifying patter
by jazir1979
Hi all,
The above 2 tags do not play nicely together if you do not specify a date format pattern.
s:converDateTime correctly uses the current locale to format the date, which can result in my input box containing say 'dd/mm/yyyy', 'mm/dd/yyyy' or 'dd-mm-yyyy' depending on my locale. This is great.
However, if no pattern is specified on s:selectDate, it always default the javascript CAL_DATE_FORMAT variable to "MM/dd/yyyy", which results in much confusion in a dd/mm/yyyy locale, eg- the wrong month popping up to what you'd expect, the wrong date getting saved, etc.
Would it be possible for s:selectDate defaulted to an appropriate format based on the current locale?
As a workaround in the meantime, we are always going to specify the appropriate format for the current locale using an EL function, but it would be nice if this "just worked".
cheers,
Daniel.
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4036200#4036200
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4036200
19 years