[Messaging, JMS & JBossMQ] - OracleThinPersistenceManager instability
by barnaby33
When testing a normal failure mode using oracle thin persistence manager I get an exception when trying to add new messages. The sequence goes like this
1) Add 2 messages to the queue. ( On checking the jms_messages table there appears to be 4 messages being written. I assume it has something to with the blob workaround but not sure.)
2) Make sure MDB cannot deliver messages.
3) Turn off server without exiting JBoss. (This seems to be a very normal failure condition to me)
4)Turn on Jboss server. (During startup JMS system barfs on the two records with null blobs. I worked around this by modifying the select query to only return messages with non-null blobs.)
5)Add more messages. This causes a SQL exception because each time you restart the server, the messageid is reset to zero. (I looked through the code to find that little nugget.)
So I'd like to sub-class the oraclethinpersistence manager and goto the jms_messages table to find out what its highest messageId is, then increment it by one and use this as the messageid for the new message. I wrote a class that does just that but when I startup jboss I get an exception along the lines of major and minor version are incorrect. Is there something preventing me administratively, say an xml config option, that I need to change? Whats are some other alternatives to my situation?
Josh
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4073225#4073225
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4073225
18Â years, 10Â months
[EJB 3.0] - Transaction is not active after rollback
by X490812
The issue is that I have a stateless EJB using CMT with the following problem:
a function X, having default transaction attribute (required) has a loop and calls another function Y with a transaction attribute of REQUIRES_NEW. Function Y does a SessionContext.setRollbackOnly. First itration calls Function Y, does rollback and exits. Second iteration of loop, function Y is called and I get the following; the error occurs during the getConnection() call in the JBPMDao.removeEndedProcesses(pidVec) function (see below)
anonymous wrote : org.jboss.util.NestedSQLException: Transaction is not active: tx=TransactionImpl:XidImpl[FormatId=257, GlobalId=ro-0029aits/49, BranchQual=, localId=49]; - nested throwable: (javax.resource.ResourceException: Transaction is not active: tx=TransactionImpl:XidImpl[FormatId=257, GlobalId=ro-0029aits/49, BranchQual=, localId=49])
Here is the code
| /**
| * Method: cleanupEndedProcesses
| * Purpose: Called from a servlet to cleanup runtime data for ended processinstances
| * @param processId
| */
| public void cleanupEndedProcesses(String processId)
| {
|
| JbpmDAO jbpmDAO = null;
| Vector<String> pidVec = new Vector<String>();
| List<String> tmpList;
| int cnt = 0;
| int BATCHSIZE = 500;
| int endNdx = 0;
|
| try {
| logger.debug("cleanupEndedProcesses:: start");
| jbpmDAO = new JbpmDAO();
| pidVec = jbpmDAO.getEndedProcesses(processId);
| while (pidVec.size() > 0)
| {
| endNdx = pidVec.size() > BATCHSIZE? BATCHSIZE:pidVec.size();
| tmpList = new ArrayList<String>(pidVec.subList(0, endNdx));
| batchRemoveEndedProcesses(tmpList, jbpmDAO);
| cnt += endNdx;
| pidVec.removeAll(tmpList);
| }
| }
| catch (Exception e) {
| throw new WorkflowException(e);
| }
| logger.debug("cleanupEndedProcesses:: pids removed = " + cnt);
|
| }
|
|
| /**
| * Method: batchRemoveEndedProcesses
| * Purpose: separated out so that we could batch deletes
| * @param pidVec
| * @param jbpmDAO
| */
| @TransactionAttribute(javax.ejb.TransactionAttributeType.REQUIRES_NEW)
| private void batchRemoveEndedProcesses(List<String> pidVec, JbpmDAO jbpmDAO)
| {
| try {
| jbpmDAO.removeEndedProcesses(pidVec);
| context.setRollbackOnly();
| }
| catch (Exception e) {
| throw new WorkflowException(e);
| }
| }
|
| public void removeEndedProcesses(List<String> pidVec)
| {
| String strQuery = DELETE_JBPM_PROCESSINSTANCES;
| Connection con = null;
| PreparedStatement pstmt = null;
|
| try {
| con = getJbpmDataSource().getConnection();
| String strInClause = constructInClause(pidVec);
| strQuery = strQuery.replaceAll(":list", strInClause);
| pstmt = con.prepareStatement(strQuery);
| bindVarsToInClause(pidVec, 1, pstmt);
| pstmt.executeUpdate();
| }
| catch (SQLException e) {
| throw new LoggableEJBException(e);
| }
| finally {
| try {
| if (pstmt != null)
| pstmt.close();
| if (con != null)
| con.close();
| }
| catch (SQLException e) {
| throw new LoggableEJBException(e);
| }
| }
|
| }
|
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4073223#4073223
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4073223
18Â years, 10Â months
[EJB 3.0] - Re: Working example por OneToMany cascade remove?
by waynebaylor
here's an example i just tested:
| @Entity
| public class Parent
| {
| @Id
| @GeneratedValue
| private Long id;
|
| @OneToMany(mappedBy="parent", cascade=CascadeType.REMOVE)
| private Set<Child> children = new HashSet<Child>();
|
| public Set<Child> getChildren()
| {
| return children;
| }
|
| public void setChildren(Set<Child> children)
| {
| this.children=children;
| }
|
| public Long getId()
| {
| return id;
| }
| }
| ==========================
|
|
| @Entity
| public class Child
| {
| @Id
| @GeneratedValue
| private Long id;
|
| @ManyToOne
| private Parent parent;
|
| private String name;
|
| public Child(){}
|
| public Child(String name)
| {
| this.name = name;
| }
| ...
| }
|
and here is the code that creates and removes the entities:
@Stateless
| @Local(TesterLocal.class)
| @LocalBinding(jndiBinding="session.Tester/local")
| public class Tester implements TesterLocal
| {
| @PersistenceContext(unitName="PU2")
| private EntityManager em;
|
| public void doWork()
| {
| Parent p = new Parent();
| em.persist(p);
|
| for(int i=0; i<5; ++i)
| {
| Child c = new Child("child-"+i);
| c.setParent(p);
| p.getChildren().add(c);
|
| em.persist(c);
| }
| em.flush();
| p = null;
|
| Parent pp = em.find(Parent.class, 1L); //i know the id is 1
| em.remove(pp);
| em.flush();
| }
| }
this code does not throw any exceptions. checking the DB i can see that the parent and all children are removed.
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4073219#4073219
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4073219
18Â years, 10Â months
[JBoss Portal] - Re: Tool for developing JSF controls in JBoss portal
by aerostra
Hi,
I've been doing a project using Java Studio Creator(JSC) so I'll let you know a few of my thoughts and discoveries below.
Firstly, I'm under the impression that Netbeans 6.0 is primarily for Java 6 and Jboss Portal works only with 1.4 & 1.5 (or v5). Just a point you should be aware of but someone correct me if I'm wrong. I also believe that the current version 5.x doesn't support the same functionality in Portlet design as JSC and v6 isn't going to do so for a while hence the preview downloads as it's one of the drawbacks of me not moving to it just yet as I like the drag n drop of JSC portlet production.
Ok, my experiences of using JSC with Jboss Portal. If you like a challenge then it is great fun (ok, my idea of fun!) but you will need to do some background work to make it work properly. Its a nice learning curve and quite satisfying seeing it work in JBP. The Jboss/JSC Wiki entry is a very good start but I've also discovered that if you want to assign portlets to roles/users you will need to read the manual and create a file - I'll post something about it sometime in the next few days as it saved me a lot of issues and time - otherwise, you can just drop a portlet in as per the wiki entry and it will work.
FYI: I use Java 1.5.x, JBP 2.4.1, MySql v5.0 and JSC 2 update 1 (full updates) for development on Windows XP and a live server running Solaris 10 with the same versions of JBP/MySql. They both work almost perfectly (a couple of minor issues but nothing major) as long as you added the additional files required by Jboss Portal.
What doesn't work and it is documented (somewhere on the forum) are certain components. Something to do with the implementation of Myfaces and the JSC version. Most of the "Basic" components work (I have not used all of them as my project didn't need to) apart from the "Table" component.
The BASIC table in JSC gives you a sort by column and this sends out a stream of error messages in JBP when it is used. Fortunately, the workaround is to just untick the table "sortable" box. That removes the sorting ability and the table works fine as does the "first/next" page type of thing you were asking in the first post. You can also set the number of rows returned. The major issue you will discover about the BASIC table component is that the empty message i.e. no results returned/found will also give you an endless stream of error data. I worked around it by running a separate SQL query to get a result and then allow the page with the table to be shown otherwise redirect it. Not exactly elegant but it works. The STANDARD table component does not give this error.
Setting it up as Master detail (e.g. as a hyperlink to another page) works fine as my project relies heavily on that type of relationship. You can use the "Standard" component table but it requires a little more work to get the same functionality. You can guess correctly I didn't go down that route ;-)
I have not used EJB nor graphical display yet so cannot comment. I guess the only way is to try it and see. There is something about using Jfreegraph (?) on the JSC forums but I don't think anyone has tried it with a portlet. Oh and the golden rule of using JSC and portlets: SessionBean. Just remember that portlets use the session bean not the request bean.
There is still a lot of JSC functionality I haven't discovered yet but I've found that JSC is a good start as an IDE providing you spend the time to learn it and are happy to compromise on certain things. Don't expect to jump straight in and produce something you want as it will be really frustrating especially with portlets and JBP.
Another thing you should be aware of is using the right database. My original choice was the JBP recommendation of Postgresql. This does work with JSC but I discovered a problem with Postgresql and JSC (think it was something to do with dropdown binding to the database) so I ended up swapping to MySql v5 (which obviously works well as I've mentioned above). Tried v4 but unfortunately v4 doesn't support views which I needed. Would like to have used Apache Derby but at the time I couldn't get it to work properly with JBP. Something I'll be trying to work on in the near future as ideally I'd want a pure java solution for a portal rather than the reliance on an RDMS.
Finally, I'd also suggest you look into learning Hibernate as one of the pains of JSC is database access. Hibernate is the next learning topic for me! I could go into more detail but summarising, it was easier to use JDBC in certain instances and not the cached rowset.
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4073213#4073213
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4073213
18Â years, 10Â months
[Installation, Configuration & DEPLOYMENT] - Re: why need to restart jboss after network changed
by john_wooï¼ canada.com
"salewski" wrote : Perhaps you're getting bit by Java's default DNS caching?
|
| http://www.rgagnon.com/javadetails/java-0445.html
| http://java.sun.com/j2se/1.5.0/docs/guide/net/properties.html
|
| From $JRE/lib/security/java.security:
|
| #
| # The Java-level namelookup cache policy for successful lookups:
| #
| # any negative value: caching forever
| # any positive value: the number of seconds to cache an address for
| # zero: do not cache
| #
| # default value is forever (FOREVER). For security reasons, this
| # caching is made forever when a security manager is set.
| #
| # NOTE: setting this to anything other than the default value can have
| # serious security implications. Do not set it unless
| # you are sure you are not exposed to DNS spoofing attack.
| #
| #networkaddress.cache.ttl=-1
|
Thanks lots.
now I set the as following
networkaddress.cache.ttl=2
networkaddress.cache.negative.ttl=2
but if jboss started when the cable is connected, and then unplug the cable (or no internet connection), the client app will have :
org.jboss.remoting.CannotConnectException: Can not get connection to server. Problem establishing socket connection.
after that, if cable recovered, then thing is ok;
if jboss started when cable is unplug, then it doesn't matter whether cable is plug in and plug off, both jboss and client app are working fine.
so my question is, how to set, so jboss/client always keep running fine regardless cable (both jboss and client ran in same machine)?
Thanks
John
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4073210#4073210
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4073210
18Â years, 10Â months