[EJB 3.0] - Multiple Persistence Unit
by go_rags
Hi,
I am trying to access 2 different datasources in my EAR. We have a MySQL database for all the standard operations, i am now trying to access a few tables from a differnt datasource.
The primary tables are accessed without a persistenceUnit, by using theDefaultDS configured. (i.e. I did not provide a unitName while creating the EntityManager)
So I added a persistence.xml to the META-INF with the following lines assuming the new entities and bean will use the unit-name provided in the persistence.xml. I have one entity called T1 and a bean to access it.
| <?xml version="1.0" encoding="UTF-8"?>
| <persistence>
| <persistence-unit name="ragsDemo">
| <provider>org.hibernate.ejb.HibernatePersistence</provider>
| <class>com.rags.test.T1</class>
| <jta-data-source>java:/TestDS</jta-data-source>
| <properties>
| <property name="hibernate.dialect" value="org.hibernate.dialect.MySQLDialect"/>
| <!-- <property name="hibernate.hbm2ddl.auto" value="create-drop"/> -->
| <!-- <property name="hibernate.hbm2ddl.auto" value="update"/> -->
| </properties>
| </persistence-unit>
| </persistence>
|
In the bean code i am creating the Entity manager using the following lines
| @PersistenceContext(unitName="ragsDemo")
| EntityManager em;
|
But when I deploy I am getting the following error :
| --- MBeans waiting for other MBeans ---
| ObjectName: jboss.j2ee:service=EJB3,name=com.rags.test.T1AccessBean
| State: FAILED
| Reason: java.lang.RuntimeException: unable to find: java:/managedEntityFactories/ragsDemo
|
I am using JBoss 4.0.3 SP1, can somebody tell me where I am going wrong.
Thanks.
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=3973418#3973418
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=3973418
19 years, 7 months
[Clustering/JBoss] - Problem Losing Sessions
by risenhoover
Hi All,
I have been experiencing a persistent issue with my JBoss cluster losing session state. I have tried everything I can think of.
My application is set up to place a User object into the session at login time and to retrieve that user object from the session with each request to the server. If the user object is not in the session, the user is redirected to the login page.
Configuration is three Linux servers, JRocket, JBoss 4.0.4GA.
1. Session timeout is set for 10 hours.
2. Clustering is turned on for all the servers, and I have verified that, at a basic level, sessions are being propagated. I tested this by logging onto the application, confirming that I was being sent to one machine, then killing that machine, and verifying that I was able to continue using the application without logging back in.
3. I am using Apache 2.2.2 w/ ajp13 load balancing, as described by the following wiki page:
http://wiki.jboss.org/wiki/Wiki.jsp?page=UsingMod_jk1.2WithJBoss
It appears that even though I have sticky sessions turned on, and even though I have JBoss clustering turned on, several times a day I am logged out of the application due to my user object being lost.
Even if I set up the load balancer to point me to only one machine, the sessions are lost.
Can anybody advise?
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=3973417#3973417
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=3973417
19 years, 7 months
[JBossWS] - Re: Consuming .net Web Service using JBOSSWS
by vimalm
I got around this error. It was aparently an issue with proxy which got resolved.
However with the current client code I am getting
| java.rmi.RemoteException: Call invocation failed with code [Client] because of: Server did not recognize the value of HTTP Header SOAPAction: .; nested exception is:
| javax.xml.rpc.soap.SOAPFaultException: Server did not recognize the value of HTTP Header SOAPAction: .
| at org.jboss.ws.jaxrpc.CallImpl.invokeInternal(CallImpl.java:713)
| at org.jboss.ws.jaxrpc.CallImpl.invoke(CallImpl.java:404)
| at org.jboss.ws.jaxrpc.CallProxy.invoke(CallProxy.java:148)
| at $Proxy0.getUserList(Unknown Source)
| at somewebsite.Test.call(Test.java:38)
| at somewebsite.Test.main(Test.java:19)
| Caused by: javax.xml.rpc.soap.SOAPFaultException: Server did not recognize the value of HTTP Header SOAPAction: .
| at org.jboss.ws.jaxrpc.SOAPFaultExceptionHelper.getSOAPFaultException(SOAPFaultExceptionHelper.java:100)
| at org.jboss.ws.binding.soap.SOAPBindingProvider.unbindResponseMessage(SOAPBindingProvider.java:486)
| at org.jboss.ws.jaxrpc.CallImpl.invokeInternal(CallImpl.java:702)
| ... 5 more
|
Doing some research around the forums I figured I neeed to use the Call object to set this SoapAction stuff. So I modified code like
| Call call = service.createCall();
| call.setOperationName(new QName("http://somewebsite.net/", "GetUserList"));
| call.setProperty(Call.SOAPACTION_USE_PROPERTY, Boolean.TRUE);
| call.setProperty(Call.SOAPACTION_URI_PROPERTY, "http://somewebsite.net/GetUserList");
| call.setTargetEndpointAddress("http://someurl/services/usermanagement.asmx");
| GetUserList gul = new GetUserList("notfound");
| //String str = "notfound";
| Object response = call.invoke(new Object[] {gul});
|
It still does not work with following error:
| javax.xml.rpc.JAXRPCException: Cannot obtain operation meta data for: {http://somewebsite.net/}GetUserList
| at org.jboss.ws.jaxrpc.CallImpl.getOperationMetaData(CallImpl.java:840)
| at org.jboss.ws.jaxrpc.CallImpl.getOperationMetaData(CallImpl.java:820)
| at org.jboss.ws.jaxrpc.CallImpl.invokeInternal(CallImpl.java:618)
| at org.jboss.ws.jaxrpc.CallImpl.invoke(CallImpl.java:404)
| at somewebsite.Test.call(Test.java:48)
| at somewebsite.Test.main(Test.java:19)
|
I am lost...
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=3973414#3973414
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=3973414
19 years, 7 months
[EJB 3.0] - Re: EJB3 MDBs & JCA Message inflow with foreing JMS provider
by S0d0
Here is sonic jndi loader conf.
|
| <?xml version="1.0" encoding="UTF-8"?>
| <server>
| <mbean code="com.sonicsw.sonicmq.asi.jndiloader.jboss.JBossLoader" name="sonic.jndiloader:service=JNDILoader">
| <attribute name="LoaderConfigURL">file:/C:/jboss-4.0.4.GA/server/default/data/sonic-jndiloader-conf.xml</attribute>
| <depends>jboss:service=Naming</depends>
| </mbean>
|
| </server>
|
|
|
| <?xml version="1.0"?>
| <sonicloader>
| <jndiEnvironment>
| <property name="java.naming.provider.url">jnp://localhost:1099</property>
| <property name="java.naming.factory.initial">org.jnp.interfaces.NamingContextFactory</property>
| <property name="java.naming.factory.url.pkgs">org.jboss.naming:org.jnp.interfaces</property>
| <property name="java.naming.referral">throw</property>
| </jndiEnvironment>
|
| <entities>
| <!-- SonicMQ Destinations -->
| <!-- Make sure these destinations have been created on the SonicMQ broker -->
| <!-- Queues -->
| <entity jndiName="SonicJMS/Queues/SampleQ1" class="progress.message.jclient.Queue">
| <property name="queueName">SampleQ1</property>
| </entity>
| <entity jndiName="SonicJMS/Queues/SampleQ2" class="progress.message.jclient.Queue">
| <property name="queueName">SampleQ2</property>
| </entity>
| <entity jndiName="SonicJMS/Queues/SampleQ3" class="progress.message.jclient.Queue">
| <property name="queueName">SampleQ3</property>
| </entity>
|
|
| <entity jndiName="SonicJMS/Queues/fromCustomer" class="progress.message.jclient.Queue">
| <property name="queueName">SampleQ1</property>
| </entity>
|
| <entity jndiName="SonicJMS/Queues/toCustomer" class="progress.message.jclient.Queue">
| <property name="queueName">SampleQ2</property>
| </entity>
|
| <entity jndiName="SonicJMS/Queues/toESB" class="progress.message.jclient.Queue">
| <property name="queueName">toESB</property>
| </entity>
|
| <entity jndiName="SonicJMS/Queues/fromESB" class="progress.message.jclient.Queue">
| <property name="queueName">fromESB</property>
| </entity>
|
| <entity jndiName="SonicJMS/Queues/errorsQueue" class="progress.message.jclient.Queue">
| <property name="queueName">errors</property>
| </entity>
|
| <entity jndiName="SonicJMS/Queues/trackingQueue" class="progress.message.jclient.Queue">
| <property name="queueName">tracking</property>
| </entity>
|
|
|
| <!-- Topics -->
| <entity jndiName="SonicJMS/Topics/SampleT1" class="progress.message.jclient.Topic">
| <property name="topicName">SampleT1</property>
| </entity>
| <entity jndiName="SonicJMS/Topics/SampleT2" class="progress.message.jclient.Topic">
| <property name="topicName">SampleT2</property>
| </entity>
| <entity jndiName="SonicJMS/Topics/SampleT3" class="progress.message.jclient.Topic">
| <property name="topicName">SampleT3</property>
| </entity>
| <entity jndiName="SonicJMS/Topics/SampleT4" class="progress.message.jclient.Topic">
| <property name="topicName">SampleT4</property>
| </entity>
|
| </entities>
| </sonicloader>
|
|
|
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=3973412#3973412
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=3973412
19 years, 7 months
[JCA/JBoss] - Re: SQL Trace output concern with mapped DS
by wcydaip
Weston,
Thanks for the reply.
The AppHelper works like a ServiceLocator. One place to call and get whichever ds is needed. I added the Singleton thought it made sense. :)
I began caching the ds references early on and realized that was a bad choice, so, the reset is basically an old call that I never changed.
Here's the AppHelper with the excluded methods:
| public static synchronized AppHelper getInstance() {
| logger.debug("entering getInstance()");
| appHelperInstance = (null == appHelperInstance) ?
| new AppHelper() : appHelperInstance;
| logger.debug("leaving getInstance()");
| return appHelperInstance;
| }
|
| private AppHelper(){
| logger.debug("creating the AppHelper Singleton");
| logger.debug("leaving AppHelper Singleton");
| }
|
| private DataSource initializeDataSource(String dataSourceJNDI) throws NamingException{
| logger.debug("entering initializeDataSource()");
| DataSource dataSource = null;
| try{
| InitialContext ic = new InitialContext();
| dataSource = (DataSource) ic.lookup(dataSourceJNDI);
| }catch (NamingException ne){
| throw new NamingException("NamingException while looking" +
| " up DataSource Connection "
| + ": \n" + ne.getMessage());
| }
| logger.debug("leaving initializeDataSource()");
| return dataSource;
| }
|
| synchronized public Connection getConnection(String ds)throws NamingException, SQLException
| {
| logger.debug("entering getConnection()");
| logger.info("get connection for "+ds);
|
| DataSource dataSource = initializeDataSource(ds);
|
| Connection conn = null;
|
| try {
| conn = dataSource.getConnection();
| logger.info("connection:"+conn.toString());
| } catch (NullPointerException e) {
| logger.error("caught np exception getting connection from cached resource!");
| logger.info("attempting to restart the datasource...");
| /*
| * If the dataSource has been shutdown or perhaps
| * the database server has been restarted, then, these
| * exception handlers will restart the datasource...
| * NOTE: All works fine if a user is in the middle of using the app,
| * however, since the Security relies on JBoss CMP then
| * are unable to authenticate
| */
| conn = resetDataSource(ds);
| logger.info("connection established!");
| } catch (SQLException e) {
| logger.error("caught sql exception getting connection from cached resource!");
| logger.info("sql ex->"+e.getMessage());
| logger.info("attempting to restart the datasource...");
| /*
| * If the dataSource has been shutdown or perhaps
| * the database server has been restarted, then, these
| * exception handlers will restart the datasource...
| * NOTE: All works fine if a user is in the middle of using the app,
| * however, since the Security relies on JBoss CMP then
| * are unable to authenticate
| */
| conn = resetDataSource(ds);
| logger.info("connection established!");
| }
|
| //conn.setAutoCommit(true);
| logger.debug("leaving getConnection()");
| return conn;
| }
|
| private Connection resetDataSource(String dataSourceJNDI)throws NamingException, SQLException{
| // try and restart it
| DataSource ds = initializeDataSource(dataSourceJNDI);
| return ds.getConnection();
| }
|
The data source's are:
| <datasources>
| <local-tx-datasource>
| <jndi-name>DefaultDS</jndi-name>
|
| <connection-url>jdbc:microsoft:sqlserver://####:1433;DatabaseName=Main;SelectMethod=cursor</connection-url>
| <driver-class>com.microsoft.jdbc.sqlserver.SQLServerDriver</driver-class>
| <user-name>reg</user-name>
| <password>****</password>
| <check-valid-connection-sql>SELECT * FROM Site(NOLOCK) WHERE SiteID = 179</check-valid-connection-sql>
| <!-- pooling parameters -->
| <min-pool-size>5</min-pool-size>
| <max-pool-size>10</max-pool-size>
| <!-- corresponding type-mapping in the standardjbosscmp-jdbc.xml (optional) -->
| <metadata>
| <type-mapping>MS SQLSERVER2000</type-mapping>
| </metadata>
| <idle-timeout-minutes>0</idle-timeout-minutes>
| </local-tx-datasource>
| </datasources>
|
And the other:
| <datasources>
| <local-tx-datasource>
| <jndi-name>CATS_DS_MAIN</jndi-name>
|
| <connection-url>jdbc:microsoft:sqlserver://####:1433;DatabaseName=Main;SelectMethod=cursor</connection-url>
| <driver-class>com.microsoft.jdbc.sqlserver.SQLServerDriver</driver-class>
| <!-- Use the security domain defined in conf/login-config.xml -->
| <security-domain>PortalCatsEncryptDBPassword</security-domain>
| <!-- ensures a valid connection -->
| <check-valid-connection-sql>SELECT * FROM Site(NOLOCK) WHERE SiteID = 179</check-valid-connection-sql>
| <!--pooling parameters-->
| <min-pool-size>5</min-pool-size>
| <max-pool-size>10</max-pool-size>
| <idle-timeout-minutes>0</idle-timeout-minutes>
| <!-- corresponding type-mapping in the standardjbosscmp-jdbc.xml (optional) -->
| <metadata>
| <type-mapping>MS SQLSERVER2000</type-mapping>
| </metadata>
| </local-tx-datasource>
| </data-sources>
|
and the login-config entry:
| <application-policy name = "PortalCatsEncryptDBPassword">
| <authentication>
| <login-module code = "org.jboss.resource.security.SecureIdentityLoginModule"
| flag = "required">
| <module-option name = "username">portal</module-option>
| <module-option name = "password">-1c4fcf3f77be50b7</module-option>
| <module-option name = "managedConnectionFactoryName">jboss.jca:service=LocalTxCM,name=CATS_DS_MAIN</module-option>
| </login-module>
| </authentication>
| </application-policy>
|
The trace is done using the SQL Profiler. The expected login was reg, however, the trace shows the Insert and Updates performed by portal.
Thanks again.
Graham
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=3973410#3973410
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=3973410
19 years, 7 months