Technical Blog

2 Posts tagged with the server tag

Remote debugging with Eclipse can be useful in many cases, especially if the server you'd like to debug isn't running through Eclipse, either locally or remotely. The following steps will configure remote debugging for JBoss. You'll need to adjust them a bit for other servers.

 

Changes to Server

  1. Locate the bin folder of the server you are running
  2. Add the following JAVA_OPTS setting to run.bat
    • set JAVA_OPTS=-Xdebug -Xrunjdwp:transport=dt_socket,address=8787,server=y,suspend=n %JAVA_OPTS%
  3. Relaunch your server

 

In Eclipse

  1. Launch the Debug Configurations window (Run -> Debug Configurations)
  2. In the Debug Configurations window, create a new Remote Java Application
    • Name: Enter name for the new configuration
    • Connection Type: Standard (Socket Attach)
    • Host: Enter IP address server is at
    • Port: Port number specified in JAVA_OPTS above (This example uses 8787)
  3. Attach the source code that's running on the remote server:
    • In the Source tab, click Add...
    • Select Java Project and click OK
    • Add the following projects: 
      • com.elasticpath.connect
      • com.elasticpath.cm
      • com.elasticpath.search
      • com.elasticpath.sf
      (Note that com.elasticpath.core will be added automatically)
    • Click Apply
  4. Click Debug
    • At this point, if you are in the Java Perspective in Eclipse, you won't see anything different
  5. Change perspectives by going to Windows -> Open Perspective -> Others...
  6. Select Debug and click OK

 

Now you're ready to debug JBoss!

 

To debug, simply set breakpoints in parts of the code you're interested in and debugging is exactly the same as if the server was running within Eclipse!

 

For more information, you can refer to the following links:

0 Comments Permalink

So, you've imported all your Elastic Path projects into Eclipse. You've set up Tomcat to run your Elastic Path web apps from within Eclipse and you've configured the log4j.properties for each web app. You launch the server. Your web apps don't start. What did you do wrong?

 

You check your web app logs. Buried deep in the stack trace, you see this:

 

Caused by: <openjpa-1.0.1-ep-6.1-1-rsvnversion: invalid option:  nonfatal user error> org.apache.renamed.openjpa.persistence.ArgumentException: [Error while processing persistent field com.elasticpath.domain.order.impl.OrderImpl.status, declared in null. Error details: The accessor for field setStatus in type com.elasticpath.domain.order.impl.OrderImpl is private or package-visible. OpenJPA requires accessors in unenhanced instances to be public or protected. If you do not want to add such an accessor, you must run the OpenJPA enhancer after compilation, or deploy to an environment that supports deploy-time enhancement, such as a Java EE 5 application server.]

 

The clue here is this:

 

you must run the OpenJPA enhancer after compilation

 

OpenJPA does bytecode enhancement on Elastic Path's persistent classes. You can learn the details of why and how in this article on OpenJPA bytecode enhancement, but if you just want to start your web apps, here's what you need to do:

  1. In Eclipse, expand the com.elasticpath.core project.
  2. Select coreAntJpaEnhance.launch.
  3. Right-click and choose Run As -> coreAntJpaEnhance.

 

You usually need to do this when you first set up your Elastic Path dev environment. After that, you need to do it whenever you modify persistent classes (basically the com.elasticpath.domain.**/*Impl classes in the com.elasticpath.core project). The jar target in the com.elasticpath.core project will do the enhancement and install it in your Maven repository, so make sure you use it before rebuilding your web apps.

 

But sometimes, it doesn't work...

There is a workaround:

  1. In the project explorer in Eclipse, select the web app project's root node.
  2. In the Project menu, choose Properties.
  3. Select Maven, and uncheck Resolve dependencies from Workspace projects.

The projects will now use the core jar that was built last time the com.elasticpath.core/build.xml jar target was run.

 

It's still not working!

If you have persistent classes that are not in the com.elasticpath package structure, you need to modify the openjpa enhance task call in the enhance target of openjpa.xml to include your packages:

 

<openjpac>
      <config propertiesFile="${src.main.java.dir}/META-INF/persistence-renamed.xml"/>
      <classpath refid="classpath"/>
      <fileset dir="${target.classes.main.dir}">
   <include name="com/elasticpath/domain/**/impl/*.class"/>
   <include name="com/my/package/**/impl/*.class"/>
      </fileset>
</openjpac>

 

Hopefully, that will get you through most of your OpenJPA related enhance problems :-)

0 Comments Permalink