Tuesday, May 6, 2014

org.hibernate.MappingException: Unknown entity:

Hi Guys ,

org.hibernate.MappingException: Unknown entity:  is a common error you may face while runtime .
I have faced this error while a bean call . A session bean of type entity . This can come due to several reasons based on your project .Some of them are as below:
1.In your persistence.xml you need to dd that particular class like as below :
            <class>model.Account</class>

If it is not set you might face the following exception .
01:09:51,133 ERROR [org.jboss.as.ejb3.invocation] (http-localhost/127.0.0.1:8088-2) JBAS014134: EJB Invocation failed on component AccountBean for method public abstract model.Account org.project.banking.AccountRemote.findAccount(model.Account): javax.ejb.EJBException: java.lang.IllegalArgumentException: Unknown entity: model.Account
at org.jboss.as.ejb3.tx.CMTTxInterceptor.handleExceptionInOurTx(CMTTxInterceptor.java:189) [jboss-as-ejb3-7.3.0.Final-redhat-14.jar:7.3.0.Final-redhat-14]
at org.jboss.as.ejb3.tx.CMTTxInterceptor.invokeInOurTx(CMTTxInterceptor.java:274) [jboss-as-ejb3-7.3.0.Final-redhat-14.jar:7.3.0.Final-redhat-14]
at org.jboss.as.ejb3.tx.CMTTxInterceptor.required(CMTTxInterceptor.java:339) [jboss-as-ejb3-7.3.0.Final-redhat-14.jar:7.3.0.Final-redhat-14]
at org.jboss.as.ejb3.tx.CMTTxInterceptor.processInvocation(CMTTxInterceptor.java:238) [jboss-as-ejb3-7.3.0.Final-redhat-14.jar:7.3.0.Final-redhat-14]
at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:288) [jboss-invocation-1.1.2.Final-redhat-1.jar:1.1.2.Final-redhat-1]
at org.jboss.as.ejb3.remote.EJBRemoteTransactionPropagatingInterceptor.processInvocation(EJBRemoteTransactionPropagatingInterceptor.java:79) [jboss-as-ejb3-7.3.0.Final-redhat-14.jar:7.3.0.Final-redhat-14]
at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:288) [jboss-invocation-1.1.2.Final-redhat-1.jar:1.1.2.Final-redhat-1]
at org.jboss.as.ejb3.component.interceptors.CurrentInvocationContextInterceptor.processInvocation(CurrentInvocationContextInterceptor.java:41) [jboss-as-ejb3-7.3.0.Final-redhat-14.jar:7.3.0.Final-redhat-14]
at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:288) [jboss-invocation-1.1.2.Final-redhat-1.jar:1.1.2.Final-redhat-1]
at org.jboss.as.ejb3.component.interceptors.ShutDownInterceptorFactory$1.processInvocation(ShutDownInterceptorFactory.java:64) [jboss-as-ejb3-7.3.0.Final-redhat-14.jar:7.3.0.Final-redhat-14]
at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:288) [jboss-invocation-1.1.2.Final-redhat-1.jar:1.1.2.Final-redhat-1]
at org.jboss.as.ejb3.component.interceptors.LoggingInterceptor.processInvocation(LoggingInterceptor.java:59) [jboss-as-ejb3-7.3.0.Final-redhat-14.jar:7.3.0.Final-redhat-14]
at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:288) [jboss-invocation-1.1.2.Final-redhat-1.jar:1.1.2.Final-redhat-1]
at org.jboss.as.ee.component.NamespaceContextInterceptor.processInvocation(NamespaceContextInterceptor.java:50) [jboss-as-ee-7.3.0.Final-redhat-14.jar:7.3.0.Final-redhat-14]
at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:288) [jboss-invocation-1.1.2.Final-redhat-1.jar:1.1.2.Final-redhat-1]
at org.jboss.as.ejb3.component.interceptors.AdditionalSetupInterceptor.processInvocation(AdditionalSetupInterceptor.java:55) [jboss-as-ejb3-7.3.0.Final-redhat-14.jar:7.3.0.Final-redhat-14]
at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:288) [jboss-invocation-1.1.2.Final-redhat-1.jar:1.1.2.Final-redhat-1]
at org.jboss.as.ee.component.TCCLInterceptor.processInvocation(TCCLInterceptor.java:45) [jboss-as-ee-7.3.0.Final-redhat-14.jar:7.3.0.Final-redhat-14]
at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:288) [jboss-invocation-1.1.2.Final-redhat-1.jar:1.1.2.Final-redhat-1]
at org.jboss.invocation.ChainedInterceptor.processInvocation(ChainedInterceptor.java:61) [jboss-invocation-1.1.2.Final-redhat-1.jar:1.1.2.Final-redhat-1]
at org.jboss.as.ee.component.ViewService$View.invoke(ViewService.java:165) [jboss-as-ee-7.3.0.Final-redhat-14.jar:7.3.0.Final-redhat-14]
at org.jboss.as.ejb3.remote.LocalEjbReceiver.processInvocation(LocalEjbReceiver.java:249) [jboss-as-ejb3-7.3.0.Final-redhat-14.jar:7.3.0.Final-redhat-14]
at org.jboss.ejb.client.EJBClientInvocationContext.sendRequest(EJBClientInvocationContext.java:181) [jboss-ejb-client-1.0.24.Final-redhat-1.jar:1.0.24.Final-redhat-1]
at org.jboss.ejb.client.EJBObjectInterceptor.handleInvocation(EJBObjectInterceptor.java:58) [jboss-ejb-client-1.0.24.Final-redhat-1.jar:1.0.24.Final-redhat-1]
at org.jboss.ejb.client.EJBClientInvocationContext.sendRequest(EJBClientInvocationContext.java:183) [jboss-ejb-client-1.0.24.Final-redhat-1.jar:1.0.24.Final-redhat-1]
at org.jboss.ejb.client.EJBHomeInterceptor.handleInvocation(EJBHomeInterceptor.java:83) [jboss-ejb-client-1.0.24.Final-redhat-1.jar:1.0.24.Final-redhat-1]
at org.jboss.ejb.client.EJBClientInvocationContext.sendRequest(EJBClientInvocationContext.java:183) [jboss-ejb-client-1.0.24.Final-redhat-1.jar:1.0.24.Final-redhat-1]
at org.jboss.ejb.client.TransactionInterceptor.handleInvocation(TransactionInterceptor.java:42) [jboss-ejb-client-1.0.24.Final-redhat-1.jar:1.0.24.Final-redhat-1]
at org.jboss.ejb.client.EJBClientInvocationContext.sendRequest(EJBClientInvocationContext.java:183) [jboss-ejb-client-1.0.24.Final-redhat-1.jar:1.0.24.Final-redhat-1]
at org.jboss.ejb.client.ReceiverInterceptor.handleInvocation(ReceiverInterceptor.java:125) [jboss-ejb-client-1.0.24.Final-redhat-1.jar:1.0.24.Final-redhat-1]
at org.jboss.ejb.client.EJBClientInvocationContext.sendRequest(EJBClientInvocationContext.java:183) [jboss-ejb-client-1.0.24.Final-redhat-1.jar:1.0.24.Final-redhat-1]
at org.jboss.ejb.client.EJBInvocationHandler.sendRequestWithPossibleRetries(EJBInvocationHandler.java:253) [jboss-ejb-client-1.0.24.Final-redhat-1.jar:1.0.24.Final-redhat-1]
at org.jboss.ejb.client.EJBInvocationHandler.doInvoke(EJBInvocationHandler.java:198) [jboss-ejb-client-1.0.24.Final-redhat-1.jar:1.0.24.Final-redhat-1]
at org.jboss.ejb.client.EJBInvocationHandler.doInvoke(EJBInvocationHandler.java:181) [jboss-ejb-client-1.0.24.Final-redhat-1.jar:1.0.24.Final-redhat-1]
at org.jboss.ejb.client.EJBInvocationHandler.invoke(EJBInvocationHandler.java:144) [jboss-ejb-client-1.0.24.Final-redhat-1.jar:1.0.24.Final-redhat-1]
at com.sun.proxy.$Proxy25.findAccount(Unknown Source)
at org.project.banking.Banking.getAllAccounts(Banking.java:32) [ConsultingJava.jar:]
at org.project.banking.Banking.processRequest(Banking.java:45) [ConsultingJava.jar:]
at org.project.common.router.CommonRouter.commonRoute(CommonRouter.java:63) [ConsultingJava.jar:]
at org.project.common.router.CommonRouter.route(CommonRouter.java:21) [ConsultingJava.jar:]
at org.project.common.web.CommonController.doPost(CommonController.java:69) [ConsultingJava.jar:]
at org.project.common.web.CommonController.doGet(CommonController.java:51) [ConsultingJava.jar:]
at javax.servlet.http.HttpServlet.service(HttpServlet.java:734) [jboss-servlet-api_3.0_spec-1.0.2.Final-redhat-1.jar:1.0.2.Final-redhat-1]
at javax.servlet.http.HttpServlet.service(HttpServlet.java:847) [jboss-servlet-api_3.0_spec-1.0.2.Final-redhat-1.jar:1.0.2.Final-redhat-1]
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:295)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:214)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:230)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:149)
at org.jboss.as.jpa.interceptor.WebNonTxEmCloserValve.invoke(WebNonTxEmCloserValve.java:50) [jboss-as-jpa-7.3.0.Final-redhat-14.jar:7.3.0.Final-redhat-14]
at org.jboss.as.jpa.interceptor.WebNonTxEmCloserValve.invoke(WebNonTxEmCloserValve.java:50) [jboss-as-jpa-7.3.0.Final-redhat-14.jar:7.3.0.Final-redhat-14]
at org.jboss.as.web.security.SecurityContextAssociationValve.invoke(SecurityContextAssociationValve.java:169)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:145)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:97)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:102)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:336)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:856)
at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:653)
at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:920)
at java.lang.Thread.run(Unknown Source) [rt.jar:1.7.0_51]
Caused by: java.lang.IllegalArgumentException: Unknown entity: model.Account
at org.hibernate.ejb.AbstractEntityManagerImpl.find(AbstractEntityManagerImpl.java:829) [hibernate-entitymanager-4.2.7.SP1-redhat-3.jar:4.2.7.SP1-redhat-3]
at org.hibernate.ejb.AbstractEntityManagerImpl.find(AbstractEntityManagerImpl.java:781) [hibernate-entitymanager-4.2.7.SP1-redhat-3.jar:4.2.7.SP1-redhat-3]
at org.jboss.as.jpa.container.AbstractEntityManager.find(AbstractEntityManager.java:193) [jboss-as-jpa-7.3.0.Final-redhat-14.jar:7.3.0.Final-redhat-14]
at org.project.banking.AccountBean.findAccount(AccountBean.java:42) [Bean2.jar:]
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) [rt.jar:1.7.0_51]
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) [rt.jar:1.7.0_51]
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) [rt.jar:1.7.0_51]
at java.lang.reflect.Method.invoke(Unknown Source) [rt.jar:1.7.0_51]
at org.jboss.as.ee.component.ManagedReferenceMethodInterceptorFactory$ManagedReferenceMethodInterceptor.processInvocation(ManagedReferenceMethodInterceptorFactory.java:72) [jboss-as-ee-7.3.0.Final-redhat-14.jar:7.3.0.Final-redhat-14]
at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:288) [jboss-invocation-1.1.2.Final-redhat-1.jar:1.1.2.Final-redhat-1]
at org.jboss.invocation.WeavedInterceptor.processInvocation(WeavedInterceptor.java:53) [jboss-invocation-1.1.2.Final-redhat-1.jar:1.1.2.Final-redhat-1]
at org.jboss.as.ee.component.interceptors.UserInterceptorFactory$1.processInvocation(UserInterceptorFactory.java:58) [jboss-as-ee-7.3.0.Final-redhat-14.jar:7.3.0.Final-redhat-14]
at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:288) [jboss-invocation-1.1.2.Final-redhat-1.jar:1.1.2.Final-redhat-1]
at org.jboss.invocation.WeavedInterceptor.processInvocation(WeavedInterceptor.java:53) [jboss-invocation-1.1.2.Final-redhat-1.jar:1.1.2.Final-redhat-1]
at org.jboss.as.ee.component.interceptors.UserInterceptorFactory$1.processInvocation(UserInterceptorFactory.java:58) [jboss-as-ee-7.3.0.Final-redhat-14.jar:7.3.0.Final-redhat-14]
at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:288) [jboss-invocation-1.1.2.Final-redhat-1.jar:1.1.2.Final-redhat-1]
at org.jboss.as.ejb3.component.invocationmetrics.ExecutionTimeInterceptor.processInvocation(ExecutionTimeInterceptor.java:43) [jboss-as-ejb3-7.3.0.Final-redhat-14.jar:7.3.0.Final-redhat-14]
at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:288) [jboss-invocation-1.1.2.Final-redhat-1.jar:1.1.2.Final-redhat-1]
at org.jboss.as.jpa.interceptor.SBInvocationInterceptor.processInvocation(SBInvocationInterceptor.java:47) [jboss-as-jpa-7.3.0.Final-redhat-14.jar:7.3.0.Final-redhat-14]
at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:288) [jboss-invocation-1.1.2.Final-redhat-1.jar:1.1.2.Final-redhat-1]
at org.jboss.invocation.InitialInterceptor.processInvocation(InitialInterceptor.java:21) [jboss-invocation-1.1.2.Final-redhat-1.jar:1.1.2.Final-redhat-1]
at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:288) [jboss-invocation-1.1.2.Final-redhat-1.jar:1.1.2.Final-redhat-1]
at org.jboss.invocation.ChainedInterceptor.processInvocation(ChainedInterceptor.java:61) [jboss-invocation-1.1.2.Final-redhat-1.jar:1.1.2.Final-redhat-1]
at org.jboss.as.ee.component.interceptors.ComponentDispatcherInterceptor.processInvocation(ComponentDispatcherInterceptor.java:53) [jboss-as-ee-7.3.0.Final-redhat-14.jar:7.3.0.Final-redhat-14]
at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:288) [jboss-invocation-1.1.2.Final-redhat-1.jar:1.1.2.Final-redhat-1]
at org.jboss.as.ejb3.component.pool.PooledInstanceInterceptor.processInvocation(PooledInstanceInterceptor.java:51) [jboss-as-ejb3-7.3.0.Final-redhat-14.jar:7.3.0.Final-redhat-14]
at org.jboss.invocation.InterceptorContext.proceed(InterceptorContext.java:288) [jboss-invocation-1.1.2.Final-redhat-1.jar:1.1.2.Final-redhat-1]
at org.jboss.as.ejb3.tx.CMTTxInterceptor.invokeInOurTx(CMTTxInterceptor.java:272) [jboss-as-ejb3-7.3.0.Final-redhat-14.jar:7.3.0.Final-redhat-14]

... 57 more

at org.hibernate.internal.SessionFactoryImpl.getEntityPersister(SessionFactoryImpl.java:1143) [hibernate-core-4.2.7.SP1-redhat-3.jar:4.2.7.SP1-redhat-3]
at org.hibernate.internal.SessionImpl.locateEntityPersister(SessionImpl.java:2493) [hibernate-core-4.2.7.SP1-redhat-3.jar:4.2.7.SP1-redhat-3]
at org.hibernate.internal.SessionImpl.access$1900(SessionImpl.java:175) [hibernate-core-4.2.7.SP1-redhat-3.jar:4.2.7.SP1-redhat-3]
at org.hibernate.internal.SessionImpl$IdentifierLoadAccessImpl.<init>(SessionImpl.java:2435) [hibernate-core-4.2.7.SP1-redhat-3.jar:4.2.7.SP1-redhat-3]
at org.hibernate.internal.SessionImpl$IdentifierLoadAccessImpl.<init>(SessionImpl.java:2439) [hibernate-core-4.2.7.SP1-redhat-3.jar:4.2.7.SP1-redhat-3]
at org.hibernate.internal.SessionImpl$IdentifierLoadAccessImpl.<init>(SessionImpl.java:2426) [hibernate-core-4.2.7.SP1-redhat-3.jar:4.2.7.SP1-redhat-3]
at org.hibernate.internal.SessionImpl.byId(SessionImpl.java:1071) [hibernate-core-4.2.7.SP1-redhat-3.jar:4.2.7.SP1-redhat-3]
at org.hibernate.internal.SessionImpl.get(SessionImpl.java:994) [hibernate-core-4.2.7.SP1-redhat-3.jar:4.2.7.SP1-redhat-3]
at org.hibernate.ejb.AbstractEntityManagerImpl.find(AbstractEntityManagerImpl.java:807) [hibernate-entitymanager-4.2.7.SP1-redhat-3.jar:4.2.7.SP1-redhat-3]
... 84 more

Sunday, May 4, 2014

'hibernate.dialect' not set

Hi Guys ,

'hibernate.dialect' not set  is a common error you may face while deploying your EAR . This can come due to several reasons based on your project .

Check the below stack trace ..
To find the root cause you need to check the following :
1. make sure your bean's persistance.xml is having the following entry :
             <persistence-unit name="your unit name" transaction-type="JTA">
2. make sure your jpa project's is having the same entry .
              <persistence-unit name="your unit name" transaction-type="JTA">
3. make sure your bean is using the same unit name .
            @PersistenceContext(unitName = "ConsultingJPA")

If it is not set you might face the following exception .

Caused by: org.hibernate.HibernateException: Connection cannot be null when 'hibernate.dialect' not set
at org.hibernate.service.jdbc.dialect.internal.DialectFactoryImpl.determineDialect(DialectFactoryImpl.java:98)
at org.hibernate.service.jdbc.dialect.internal.DialectFactoryImpl.buildDialect(DialectFactoryImpl.java:68)
at org.hibernate.engine.jdbc.internal.JdbcServicesImpl.configure(JdbcServicesImpl.java:174)
at org.hibernate.service.internal.StandardServiceRegistryImpl.configureService(StandardServiceRegistryImpl.java:76)
at org.hibernate.service.internal.AbstractServiceRegistryImpl.initializeService(AbstractServiceRegistryImpl.java:160)
at org.hibernate.service.internal.AbstractServiceRegistryImpl.getService(AbstractServiceRegistryImpl.java:132)
at org.hibernate.cfg.Configuration.buildTypeRegistrations(Configuration.java:1822)
at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1780)
at org.hibernate.ejb.EntityManagerFactoryImpl.<init>(EntityManagerFactoryImpl.java:96)
at org.hibernate.ejb.Ejb3Configuration.buildEntityManagerFactory(Ejb3Configuration.java:914)
... 9 more

Thursday, March 27, 2014

Jboss naming context factory and url


You might get following error while initial testing of your project

02:52:52,174 INFO  [stdout] (http-localhost/127.0.0.1:8088-1) INFO : CommonServlet do post

02:52:52,185 ERROR [stderr] (http-localhost/127.0.0.1:8088-1) javax.naming.NamingException: JBAS011843: Failed instantiate InitialContextFactory org.jnp.interfaces.NamingContextFactory from classloader ModuleClassLoader for Module "deployment.Consulting.war:main" from Service Module Loader

02:52:52,185 ERROR [stderr] (http-localhost/127.0.0.1:8088-1)  at org.jboss.as.naming.InitialContextFactoryBuilder.createInitialContextFactory(InitialContextFactoryBuilder.java:64)

02:52:52,185 ERROR [stderr] (http-localhost/127.0.0.1:8088-1)  at javax.naming.spi.NamingManager.getInitialContext(Unknown Source)

02:52:52,186 ERROR [stderr] (http-localhost/127.0.0.1:8088-1)  at javax.naming.InitialContext.getDefaultInitCtx(Unknown Source)

02:52:52,186 ERROR [stderr] (http-localhost/127.0.0.1:8088-1)  at javax.naming.InitialContext.init(Unknown Source)

02:52:52,186 ERROR [stderr] (http-localhost/127.0.0.1:8088-1)  at javax.naming.InitialContext.<init>(Unknown Source)

02:52:52,186 ERROR [stderr] (http-localhost/127.0.0.1:8088-1)  at org.framework.naming.NamingWrapper.doLookUp(NamingWrapper.java:24)


Possible solution of this problem is changing the entry in
"org.jboss.naming.remote.client.InitialContextFactory".
"remote://localhost:4447"

but still it will fail :



03:32:57,376 ERROR [stderr] (http-localhost/127.0.0.1:8088-1) javax.naming.NamingException: JBAS011843: Failed instantiate InitialContextFactory org.jboss.naming.remote.client.InitialContextFactory from classloader ModuleClassLoader for Module "deployment.Consulting.war:main" from Service Module Loader

03:32:57,376 ERROR [stderr] (http-localhost/127.0.0.1:8088-1)  at org.jboss.as.naming.InitialContextFactoryBuilder.createInitialContextFactory(InitialContextFactoryBuilder.java:64)

03:32:57,377 ERROR [stderr] (http-localhost/127.0.0.1:8088-1)  at javax.naming.spi.NamingManager.getInitialContext(Unknown Source)

03:32:57,377 ERROR [stderr] (http-localhost/127.0.0.1:8088-1)  at javax.naming.InitialContext.getDefaultInitCtx(Unknown Source)

03:32:57,377 ERROR [stderr] (http-localhost/127.0.0.1:8088-1)  at javax.naming.InitialContext.init(Unknown Source)

03:32:57,377 ERROR [stderr] (http-localhost/127.0.0.1:8088-1)  at javax.naming.InitialContext.<init>(Unknown Source)


Fed up....
Now remove the entry and create initail context with any hashtable .

You might possible get the following error

03:58:25,999 ERROR [stderr] (http-localhost/127.0.0.1:8088-1) javax.naming.NameNotFoundException: consultingDS -- service jboss.naming.context.java.consultingDS

03:58:26,000 ERROR [stderr] (http-localhost/127.0.0.1:8088-1)  at org.jboss.as.naming.ServiceBasedNamingStore.lookup(ServiceBasedNamingStore.java:103)

03:58:26,000 ERROR [stderr] (http-localhost/127.0.0.1:8088-1)  at org.jboss.as.naming.NamingContext.lookup(NamingContext.java:197)

03:58:26,000 ERROR [stderr] (http-localhost/127.0.0.1:8088-1)  at org.jboss.as.naming.InitialContext.lookup(InitialContext.java:120)

03:58:26,001 ERROR [stderr] (http-localhost/127.0.0.1:8088-1)  at org.jboss.as.naming.NamingContext.lookup(NamingContext.java:183)

03:58:26,001 ERROR [stderr] (http-localhost/127.0.0.1:8088-1)  at org.jboss.as.naming.NamingContext.lookup(NamingContext.java:179)

03:58:26,001 ERROR [stderr] (http-localhost/127.0.0.1:8088-1)  at javax.naming.InitialContext.lookup(Unknown Source)


org.jboss.as.naming.ServiceBasedNamingStore.lookup(ServiceBasedNamingStore.java:103)


Then you have to make sure that your standalone.xml and domain.xmlis updated with the datasource and driver

If you have updated domain.xml and still the same exception as above the you have to update standalone.xml
while starting server might throw the following exception :


04:04:41,444 INFO  [org.jboss.as.controller] (Controller Boot Thread) JBAS014774: Service status report
JBAS014775:    New missing/unsatisfied dependencies:
      service jboss.jdbc-driver.oracle (missing) dependents: [service jboss.driver-demander.java:/consultingDS, service jboss.data-source.java:/consultingDS]

04:04:41,564 INFO  [org.jboss.as] (Controller Boot Thread) JBAS015961: Http management interface listening on http://127.0.0.1:9990/management



Tuesday, March 11, 2014

JBOSS AS 7 JMS

Hi Guys ,

I am going to set up Jboss AS 7 using Eclipse Kepler .

First of all you need to downlaod Jboss Developer Studios for Eclipse Kepler .

You need to create a server and all that basic steps that everyone knows .

If you are using JBOSS AS 7 for the first time and if you are an overconfident JBOSS 5 user , then be prepared you might face some difficulties .

Eclipse , by default will set up Program argument for server as

-mp "D:/software/jboss-eap-6.2.0/jboss-eap-6.2/modules" -logmodule org.jboss.logmanager -jaxpmodule javax.xml.jaxp-provider org.jboss.as.standalone -b localhost -c standalone.xml

You need to change it to

-mp "D:/software/jboss-eap-6.2.0/jboss-eap-6.2/modules" -logmodule org.jboss.logmanager -jaxpmodule javax.xml.jaxp-provider org.jboss.as.standalone -b localhost -c standalone-full.xml

Remember you can start JBOSS using standalone.xml also but messaging will not be visible and hornetq server for messaging will not be started .


Tuesday, January 31, 2012

newDatabaseConnection


/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package javadatabase;

/**
 *
 * @author shahbaz
 */
import java.sql.*;
class Conn {
  public static void main (String[] args) throws SQLException
  {
      try{
   Class.forName ("oracle.jdbc.OracleDriver");//Class.forName is used to load a class from anywhere to the program
      }catch(ClassNotFoundException e){System.out.println("andu");}

   Connection conn = DriverManager.getConnection("jdbc:oracle:thin:@localhost:1521:XE", "system", "25121987");
                        // @//machineName:port/SID,   userid,  password
   try {
     Statement stmt = conn.createStatement();
     try {
       
       ResultSet rset=stmt.executeQuery("insert into MyTable values('raja',25)");
               rset = stmt.executeQuery("select * from MyTable");
       try {
         while (rset.next()){
           System.out.println (rset.getString(1)+"\t"+rset.getString(2));
         //System.out.println (rset.getString(2));// Print col 1
       } }
       finally {
          try { rset.close(); } catch (Exception ignore) {}
       }
     }
     finally {
       try { stmt.close(); } catch (Exception ignore) {}
     }
   }
   finally {
     try { conn.close(); } catch (Exception ignore) {}
   }
  }
}
/**********nex***************/
/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package javadatabase;

/**
 *
 * @author shahbaz
 */
import java.sql.*;
public class Conn1 {
    public static void main(String[] args) throws SQLException
    {
       /* Connection con=null;
                Statement s=null;
                        ResultSet rs=null;*/
        try{
            Class.forName("oracle.jdbc.OracleDriver");
        
       Connection  con=DriverManager.getConnection("jdbc:oracle:thin:@localhost:1521:XE", "system", "25121987");
        Statement s=con.createStatement();
         s.addBatch("INSERT INTO MyTable values('Rajan',30,'M')");
         
         s.addBatch("INSERT INTO MyTable values('Rajanan',31,'M')");
         //s.addBatch("SELECT * FROM MyTable");//invalid batch command
         s.executeBatch();
       /* while(rs.next())
        {
            System.out.println(rs.getString(1)); 
        }*/
    }
        catch(Exception e)
        {
            System.out.println(e);
        }
       /* finally
        {
            try{
            rs.close();
            con.close();
            s.close();
        }
            catch(Exception e)
            {
                System.out.println(e);
            }
    }*/
    }}

Monday, January 30, 2012

babylon


package javaapplication4;


import java.awt.*;
import java.io.*;
import java.util.*;
import java.net.*;


public class babylon
    extends Object
    implements Runnable
{
    public static final String VERSION = "1.0";

    public static String usernameParam     = "-username";
    public static String passwordParam     = "-password";
    public static String servernameParam   = "-servername";
    public static String portnumberParam   = "-portnumber";
    public static String chatroomParam     = "-chatroom";
    public static String widthParam        = "-xsize";
    public static String heightParam       = "-ysize";
    public static String nopasswordsParam  = "-nopasswords";
    public static String locksettingsParam = "-locksettings";
    public static String autoconnectParam  = "-autoconnect";
    public static String hidecanvasParam   = "-hidecanvas";

    private babylonWindow window;
    private URL myURL = null;/* Uniform Resource Locator, a pointer to a "resource" on the World Wide Web. A resource can be something as simple as a file or a directory, or it can be a reference to a more complicated object, such as a query to a database or to a search engine.*/
    private Class thisClass = babylon.class;//Instances of the class Class represent classes and interfaces in a //running Java application
    private String name = "";
    private String password = "";
    private String host = "";
    private String port = "";
    private String room = "";
    private int windowWidth = 0;
    private int windowHeight = 0;
    private boolean requirePasswords = true;
    private boolean lockSettings = false;
    private boolean autoConnect = false;
    private boolean showCanvas = true;

    // For managing strings according to the locale
    protected babylonStringManager strings = null;


    public babylon(String[] args)throws Exception
    {
// Get a URL to describe the invocation directory
try {
   myURL = new URL("file", "localhost", "./");
}
catch (Exception E) {
   System.out.println(E);
   System.exit(1);
}

// For managing strings according to locale
strings = new babylonStringManager(myURL,
  Locale.getDefault().getLanguage());//error

// Parse our args.  Only continue if successful
if (!parseArgs(args))
   System.exit(1);

// If "username" is blank, that's OK.  However, if the server and/or
// port are blank, we'll supply some default ones here
if ((host == null) || host.equals(""))
   host = "visopsys.org";
if ((port == null) || port.equals(""))
   port = "12468";

// Open the window
window = new babylonWindow(new babylonPanel(name, password, host,
   port, showCanvas,
   myURL));

// Set the window width and height, if applicable
Dimension tmpSize = window.getSize();
if (windowWidth > 0)
   tmpSize.width = windowWidth;
if (windowHeight > 0)
   tmpSize.height = windowHeight;
window.setSize(tmpSize);

// Make the pretty icon
window.setIcon(myURL);

// Should the window prompt users for passwords automatically?
window.contentPanel.requirePassword = requirePasswords;

// Should the user name, server name, and port name be locked
// against user changes?
window.contentPanel.lockSettings = lockSettings;

// Show the window
window.show();

// Are we supposed to attempt an automatic connection?
if (autoConnect)
   window.contentPanel.connect();
else
   window.contentPanel.offline();

// Is the user supposed to be placed in an initial chat room?
if (!room.equals(""))
   if (window.contentPanel.client != null)
try {
   window.contentPanel.client.sendEnterRoom(room, false,
"");
}
catch (IOException e) {
   window.contentPanel.client.lostConnection();
   return;
}

// Done
return;
    }

    public void run()
    {
// Nothing to do here.
return;
    }

    private void usage()
    {
System.out.println("\n" + strings.get(thisClass, "usage"));
System.out.println("java babylon [" +
  usernameParam + " name] [" +
  passwordParam + " password] [" +
  servernameParam + " host] [" +
  portnumberParam + " port] [" +
  chatroomParam + " room] [" +
  widthParam + " number] [" +
  heightParam + " number] [" +
  nopasswordsParam + "] [" +
  locksettingsParam + "] [" +
  autoconnectParam + "] [" +
  hidecanvasParam + "]");
return;
    }

    private boolean parseArgs(String[] args)
    {
// Loop through any command line arguments
for (int count = 0; count < args.length; count ++)
   {
if (args[count].equals(usernameParam))
   {
if (++count < args.length)
   name = args[count];
   }

else if (args[count].equals(passwordParam))
   {
if (++count < args.length)
   password = args[count];
   }

else if (args[count].equals(servernameParam))
   {
if (++count < args.length)
   host = args[count];
   }

else if (args[count].equals(portnumberParam))
   {
if (++count < args.length)
   port = args[count];
   }

else if (args[count].equals(chatroomParam))
   {
if (++count < args.length)
   room = args[count];
   }

else if (args[count].equals(widthParam))
   {
if (++count < args.length)
   windowWidth = Integer.parseInt(args[count]);
   }

else if (args[count].equals(heightParam))
   {
if (++count < args.length)
   windowHeight = Integer.parseInt(args[count]);
   }

else if (args[count].equals(nopasswordsParam))
   requirePasswords = false;

else if (args[count].equals(locksettingsParam))
   lockSettings = true;

else if (args[count].equals(autoconnectParam))
   autoConnect = true;

else if (args[count].equals(hidecanvasParam))
   showCanvas = false;

else if (args[count].equals("-help"))
   {
usage();
return (false);
   }

else
   {
System.out.println("\n" + strings.get(thisClass,
     "unknownarg") +
  " " + args[count]);
System.out.println(strings.get(thisClass, "forusage"));

return (false);
   }
   }

return (true);
    }

    public static void main(String[] args)
    {
        try{
babylon firstInstance = new babylon(args);
        firstInstance.run();
return;
        }
        catch(Exception e){System.out.println(e+"shahbaz");}

    }
}

Sunday, January 1, 2012

Java Taglibs Apache objective Questions

1.Which of the following is/are interface:
a.Tag
b.BodyTag
c.TagSupport
d.BodyTagSupport
Answer.(a)(b)

2.doStartTag() returns:
a.EVAL_BODY_INCLUDE
B.SKIP_BODY
C.EVAL_BODY_TAG
D.all of the above
Answer:(d)


3.doEndTag() returns:
a.EVAL_PAGE
b.SKIP_PAGE
c.both
d.none
Answer:(C)

4.Which method is invoked after body content is evaluated:
a.doInitBody()
b.doAfterBody()
c.both
d.none

Answer:(b)

5.The BodyTagSupport class implements the BodyTag interface and adds additional convenience methods which is/are:
a.getter for the bodyContent property
b.getter for the previous out JSPWriter
c.both
d.none
Answer:(c)

6. Web Application handlers must reside in one of the following standard locations for Java classes:
a.in a JAR file in the /WEB-INF/lib directory
b.in a directory in the /WEB-INF/classes directory
c.both
d.none
Answer.(c)

7. If the tag is nested, the parent handler of the enclosing tag can be accessed by using:
a.TagSupport.getParent()
b.TagSupport.findAncestorWithClass(from, class)
c.both
d.none
Answer:(c)

8.TLD is:
a. Tag Library Descriptor
b. Tag library Destructor
c Tag library Deviator
d. none
Answer (a)

9.How can u locate a TLD.
a.web.xmltaglib element
b.default mapping
c.both
d.none
Answer:c

ec2-user@ec2 Permission denied